A
Alexander Groß
Hello everybody,
I encounter problems with the Enabled-property of panels and the propagation
to subitems of the container.
Overview:
On a form there is one panel (named "A"), which surrounds all other controls
on the form (except two buttons). Inside panel A lies a checkbox. Below this
checkbox (and also inside A) panel B is located. The contents of panel B
should only be enabled if the checkbox is checked and enabled.
To implement this behaviour I attached an event handler to the
CheckedChanged-event of the checkbox. This handler enables panel B if the
checkbox is checked. A handler for the EnabledChanged-event sets panel B
enabled if the checkbox is checked and also enabled.
Below panel A there are two buttons:
- Button A toggles the Enabled-property of panel A. Panel A also changes the
Enabled-property of its contained controls (checkbox and panel B). This
propagation should be possible due to the fact that it is documented on
MSDN.
- Button B toggles the Enabled-property of the checkbox. The
EnabledChanged-event of the checkbox is fired and Panel B's Enabled-property
is also toggled.
So far so good. The problem is, that it is not working as expected.
- Initially all controls are enabled and the checkbox is checked.
- If you click button B, the checkbox and panel B are disabled. A repeated
click on button B enables them again. Correct.
- If button A is clicked, panel A is disabled. This deactivation is
propagated to the checkbox, which is disabled and then fires EnabledChanged.
The handler disables panel B as well. But panel B's contents are not redrawn
(i.e. the controls remain visually enabled). If you force to redraw panel
B's contents (by dragging the window out of the screen area) the correct
state is displayed.
Did I misunderstand the meaning of the Enabled-property or is this behaviour
by design?
For illustration purposes I wrote a little demo. Feel free to download the
sourcecode at http://it99.dyndns.org/axl/forms.zip
Best regards,
Alex
X-Post, F'Up set to microsoft.public.dotnet.framework.windowsforms
_______________________________________
Alexander Groß
Dipl.-Ing. (BA) für Informationstechnik
(e-mail address removed)
http://www.it99.org/axl
Wired: +49 (0) 3 41 / 47 84 97 70
Cellular: +49 (0) 1 75 / 410 72 68
ICQ# 36765668
_______________________________________
I encounter problems with the Enabled-property of panels and the propagation
to subitems of the container.
Overview:
On a form there is one panel (named "A"), which surrounds all other controls
on the form (except two buttons). Inside panel A lies a checkbox. Below this
checkbox (and also inside A) panel B is located. The contents of panel B
should only be enabled if the checkbox is checked and enabled.
To implement this behaviour I attached an event handler to the
CheckedChanged-event of the checkbox. This handler enables panel B if the
checkbox is checked. A handler for the EnabledChanged-event sets panel B
enabled if the checkbox is checked and also enabled.
Below panel A there are two buttons:
- Button A toggles the Enabled-property of panel A. Panel A also changes the
Enabled-property of its contained controls (checkbox and panel B). This
propagation should be possible due to the fact that it is documented on
MSDN.
- Button B toggles the Enabled-property of the checkbox. The
EnabledChanged-event of the checkbox is fired and Panel B's Enabled-property
is also toggled.
So far so good. The problem is, that it is not working as expected.
- Initially all controls are enabled and the checkbox is checked.
- If you click button B, the checkbox and panel B are disabled. A repeated
click on button B enables them again. Correct.
- If button A is clicked, panel A is disabled. This deactivation is
propagated to the checkbox, which is disabled and then fires EnabledChanged.
The handler disables panel B as well. But panel B's contents are not redrawn
(i.e. the controls remain visually enabled). If you force to redraw panel
B's contents (by dragging the window out of the screen area) the correct
state is displayed.
Did I misunderstand the meaning of the Enabled-property or is this behaviour
by design?
For illustration purposes I wrote a little demo. Feel free to download the
sourcecode at http://it99.dyndns.org/axl/forms.zip
Best regards,
Alex
X-Post, F'Up set to microsoft.public.dotnet.framework.windowsforms
_______________________________________
Alexander Groß
Dipl.-Ing. (BA) für Informationstechnik
(e-mail address removed)
http://www.it99.org/axl
Wired: +49 (0) 3 41 / 47 84 97 70
Cellular: +49 (0) 1 75 / 410 72 68
ICQ# 36765668
_______________________________________