Michael presents a very good solution. However, you can shorten your code if all of the controls are of a certain type using the OfType(Of Type) parameter. Labels are not Container Controls so the recursive function below is pointless, but you can use it for any control type you want.
Public Sub ChangeLabelColors(ByRef MainParent as Control)
If Not MainParent.HasChildren Then Exit Sub
For Each x as Label in MainParent.Controls.OfType(Of Label)
If x.HasChildren Then ChangeLabelColors(x)
If Not x.Tag = "Don't Change Me" Then
x.BackColor = My.Settings.MCB
x.ForeColor = My.Settings.MCF
End If
Next
End Sub
Simply call:
ChangeLabelColors(Me)
Alternatively, this can be modified to allow you to filter the type as well. This is basically Michael's solution that now allows recursion. I also used Select Case by choice, I believe it be faster (Not sure about that)
Public Sub ChangeControlColors(ByRef MainParent as Control)
If Not MainParent.HasChildren Then Exit Sub
For Each x as Control in MainParent.Controls()
Select Case True
Case TypeOf x Is Label, TypeOf x is Checkbox, TypeOf x is Panel
If x.HasChildren Then ChangeControlColors(x)
If Not x.Tag = "Don't Change Me" Then
x.BackColor = My.Settings.MCB
x.ForeColor = My.Settings.MCF
End If
End Select
Next
End Sub