How do I disable a container without changing the style of contained controls?

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
J

Joseph Geretz

I want to disable a whole group of controls, but I don't want to change the
UI appearance of these controls. I've placed all of these controls onto a
Group Box and so I can physically restrict access to the entire group en
masse by simply disabling the group box. When I do this, I'd like the
contained controls to remain visually unchanged.

How can this be done?

Thanks very much for your help!

Joseph Geretz
 
Does the group box have a "read-only" property that you can use? Alot of
DevExpress controls have a read-only property that I use often...
 
Hi Aaron,

We are using the standard VS GroupBox. Unfortunately, it does not provide
the ReadOnly property.

Thanks for your suggestion.

Joseph Geretz
 
Hi,

textBox1.Enabled=false;

textBox1.BackColor = Color.White;

textBox1.ReadOnly = true;

this should do the job, but hard to implement.

I recommend you to create a base Textbox class which overrides enabled property or has another property and executes the code above. After that inherit all your textboxes from this class.

Hi Aaron,

We are using the standard VS GroupBox. Unfortunately, it does not provide
the ReadOnly property.

Thanks for your suggestion.

Joseph Geretz
 
You can handle the GroupBox_Enter event. Cause it to force focus onto
another control. You can even set a flag to let the event know if it should
allow the group box to get focus or not.

VB.NET

Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox2.Enter

If Not IsAllowedFocus Then
'set focus to another control
Button3.Focus()
End If


End Sub
 
Back
Top