Every Container control has a Controls Collection which you can access to get any child controls that you need. As an example, lets say you wanted to change the BackColor of every Button Control on a Form you could use a For Loop to access the Forms Controls collection and then use the OfType(Of T) Method to get just the Buttons and then interact with each button as you need. i.e:-
For Each formButton As Button In Me.Controls.OfType(Of Button)()
formButton.BackColor = Color.AliceBlue
Next
Every Container control has a Controls Collection which you can access to get any child controls that you need. As an example, lets say you wanted to change the BackColor of every Button Control on a Form you could use a For Loop to access the Forms Controls collection and then use the OfType(Of T) Method to get just the Buttons and then interact with each button as you need. i.e:-
For Each formButton As Button In Me.Controls.OfType(Of Button)()
formButton.BackColor = Color.AliceBlue
Next
Dim Children As New List(Of System.Windows.Forms.Control)
Dim oControl As System.Windows.Forms.Control
For Each oControl In sender.parent.Controls
Children.Add(oControl)
If oControl.HasChildren Then
Children.AddRange(oControl.FindForm.MdiChildren)
End If
Next
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.