Label Fore Color Change To Black When GroupBox Is Disabled.

Hi,

I have a groupbox with several control inside.

When I disable the groupbox, all the label fore color is set to black.

I don't want to change the label fore color.

This is also happened to checkbox.

How to solve this problem?

Thank you.
LVL 1
emi_sastraAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
This work for the TextBox and CheckBox. If you want you add more:

For Each ctrl As Control In GroupBox1.Controls
            If TypeOf ctrl Is TextBox Then
                CType(ctrl, TextBox).Enabled = False
            ElseIf TypeOf ctrl Is CheckBox Then
                CType(ctrl, CheckBox).Enabled = False
            End If
        Next
0
 
SanclerCommented:
When you Enable/Disable a container control, such as a GroupBox, the .Enabled property of all the controls within that follow the setting.  So when you disable your GroupBox the Labels (and Checkboxes) within it are also disabled.  When controls are disabled, the user is given a visual clue by the appearance changing.  That is "by design", I think.  

If you don't want them to follow that behaviour, one idea would be to put them OVER rather than IN the GroupBox.  So far as Labels are concerned, that should cause no problems: because the user can do little to them anyway.  But do you still want the user to be able to change the state of a CheckBox if it is - even only apparently - part of a disabled GroupBox?

Roger
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Jorge PaulinoIT Pro/DeveloperCommented:
Why don't you loop in all the controls inside the groupbox and disable only the one you like (like checkbox, textbox) ?
0
 
emi_sastraAuthor Commented:
HI Roger,

I think I should disabled all texbox alone inside the groupbox, so it does not change the labels inside the groupbox.

How to do it?

Thank you.

0
 
emi_sastraAuthor Commented:
HI ee_rlee,

Your link is too complicated for me, and for this case I don't need to make custom controls.

Thank you.
0
 
emi_sastraAuthor Commented:
Hi jpaulino,

I agree as I just post.

Thank you.
0
 
emi_sastraAuthor Commented:
Hi jpaulino,

Thank you, that is what I need now.

0
All Courses

From novice to tech pro — start learning today.