I have a form with a collapsible group field (retrieved from http://www.codeproject.com/Articles/12835/XP-Style-Collapsible-GroupBox ). I use it mainly to show / hide additional parameters in the form. However, the group box itself is not a problem, since I did the same with the usual one Panel, that I changed the Visible property, and the problem remained the same:
When I hide this window, I want the window to shrink accordingly. So, I have the code when you click on the window title, which basically looks like this:
if (OptionsPanel.IsCollapsed)
this.Height -= (OptionsPanel.Height - OptionsPanel.CollapsedHeight);
else
this.Height += (OptionsPanel.Height - OptionsPanel.CollapsedHeight);
The problem is that when you expand the window, the window really grows accordingly, but when you reset the field, it does not decrease. In fact, nothing I do seems to be able to make the window smaller — I even tried hard-coding the window sizes, and it never gets smaller, just bigger.
Is there something that I am missing to make this work? Or is there a better component that will do it right? Honestly, I am shocked that the Toolbox does not have a default control, as this seems to be quite common, and I have seen such things in many forms. It doesn't look like you need to switch to third-party plugins or flip your own code.
source
share