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

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
 
A

Aaron Moore

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...
 
J

Joseph Geretz

Hi Aaron,

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

Thanks for your suggestion.

Joseph Geretz
 
T

Tamer Oz [MVP]

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
 
A

Aaron

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top