Need Help Only Need Help Only -5 years ago 94 Question

Is there another option to change the color of the group box text?

I want to know if there is an option to just change the group box text at the top left of the group box in a windows form and not any controls or labels located inside of the group box. I know that

groupbox.forecolor =
will change all text associated with that box to blue.

Answer Source

As long as I know, all the child controls will take the property of the parent.

You can store all your child colors and change them after you set the GroupBox's ForeColor. You can use a Dictionary with each pair of Control/Color.

Something like:

Dim cColors As New Dictionary(Of Control, Color)

For Each ctrl As Control In GroupBox1.Controls
    cColors.Add(ctrl, ctrl.ForeColor)

GroupBox1.ForeColor = Color.Blue

For Each ctrl As Control In GroupBox1.Controls
    If cColors.HasKey(ctrl) Then
        ctrl.ForeColor = cColors(ctrl)
    End If

You can put that in a method.

More information about the property at MSDN.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download