Brijesh Patel Brijesh Patel - 6 months ago 11
Vb.net Question

Enable Controls within disabled Panel in VB.Net

I have some Controls inside a Panel inside a Form. I want to disable the Panel but some Controls inside the panel need to stay enabled.

Is there any way to enable some Controls inside a disabled Panel?

I would be happy about some ideas how to do that.

Answer

One of the benefits of Panels is the can used to provide logical grouping with little or no visual element (compared to a Groupbox which is both logical AND visual). Given your question, perhaps all the child controls do not actually belong in the same container (logical group). You could use 2 or 3 panels to solve the container/child enabling problem and use the BorderStyle and BackColor properties to make them look like they are all one panel (perhaps on a master panel whose sole role is to position the children).

You can also "cascade" enabling to logically dependent elements from events. For instance, consider a checkbox "Absolute Position" which controls whether or not other controls (X Pos, Y Pos) are enabled. X and Y's enabled state can be toggled from events on chkAbsPosition such as CheckChanged and EnabledChanged.

Depending on your form, you might be able to toggle 2 or 3 controls and let each of them in turn set the state for dependent elements.

HTH

Comments