title: C# window height only gets bigger, not smaller
body: <p>I've got a form with a collapsible group box (got it from <a href="http://www.codeproject.com/Articles/12835/XP-Style-Collapsible-GroupBox" rel="nofollow">http://www.codeproject.com/Articles/12835/XP-Style-Collapsible-GroupBox</a>).  I'm using it basically to show/hide advanced options on the form.  The group-box itself is not at issue, however, as I did the same thing with just a regular <code>Panel</code> that I changed the Visible property on and the issue is the same:</p>
  
  <p>When I hide this box, I want the window to shrink accordingly.  So I've got code when you click on the box header that basically goes like:</p>
  
  <pre><code>if (OptionsPanel.IsCollapsed)
      this.Height -= (OptionsPanel.Height - OptionsPanel.CollapsedHeight);
  else
      this.Height += (OptionsPanel.Height - OptionsPanel.CollapsedHeight);
  </code></pre>
  
  <p>Problem is - when you expand the box, the window does indeed grow accordingly, but when you collapse the box, it doesn't shrink.  In fact, nothing I do seems able to make the window smaller - I've even tried hard-coding the window sizes, and it never gets smaller, only bigger.</p>
  
  <p>Is there something I'm missing to make this work?  Or is there a better component out there that will do this right?  Honestly I'm shocked that there isn't a default control in the Toolbox for doing this sort of thing, as it seems like a fairly common thing to do, and I've seen things like this on a lot of forms.  Doesn't seem like the kind of thing you should have to go to 3rd party plugins or roll your own code for.</p>