The System.Windows.Forms Control Contains method is used to determine whether the specified control is a child of the current control. The method returns a Boolean value indicating whether the specified control is contained within the current control.
Example 1: Checking if a Label control is contained within a Panel control
Panel panel1 = new Panel(); Label label1 = new Label();
panel1.Controls.Add(label1);
if(panel1.Contains(label1)) { MessageBox.Show("The label control is contained within the panel control"); }
Example 2: Removing a Button control from a Form control if it is contained within it
Form form1 = new Form(); Button button1 = new Button();
The System.Windows.Forms package library contains the Control class and its derived classes, which include all the controls used for creating graphical user interfaces in Windows Forms applications built with C#.
C# (CSharp) System.Windows.Forms Control.Contains - 19 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Forms.Control.Contains extracted from open source projects. You can rate examples to help us improve the quality of examples.