Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration Public ReadOnly Property Controls As ControlCollection 'Usage Dim instance As Control Dim value As ControlCollection value = instance.Controls
Property ValueA Control.ControlCollection representing the collection of controls contained within the control.
A Control can act as a parent to a collection of controls. For example, when several controls are added to a Form, each of the controls is a member of the Control.ControlCollection assigned to the Controls property of the form, which is derived from the Control class.
You can manipulate the controls in the Control.ControlCollection assigned to the Controls property by using the methods available in the Control.ControlCollection class.
When adding several controls to a parent control, it is recommended that you call the SuspendLayout method before initializing the controls to be added. After adding the controls to the parent control, call the ResumeLayout method. Doing so will increase the performance of applications with many controls.
The following code example removes a Control from the Control.ControlCollection of the derived class Panel if it is a member of the collection. The example requires that you have created a Panel, a Button, and at least one RadioButton control on a Form. The RadioButton control(s) are added to the Panel control, and the Panel control added to the Form. When the button is clicked, the radio button named radioButton2 is removed from the Control.ControlCollection.
' Remove the RadioButton control if it exists. Private Sub RemoveButton_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles RemoveButton.Click If Panel1.Controls.Contains(RadioAddRangeButton) Then Panel1.Controls.Remove(RadioAddRangeButton) End If End Sub
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.