title: Resize panel to fit contained elements in windows forms
body: <p>I am creating a collapsible panel element, which would essentially be a panel element with a button element and a panel element below the button.  Clicking the button causes the neighboring panel to have <code>Visible = false</code>.  I would like to resize the containing panel when the child panel is set to invisible.</p>
  
  <p>I have done this manually, by setting the <code>Size</code> property to be the sum of the widths and heights of the visible elements (either the button or the button and the child panel.)</p>
  
  <p>I am curious to know though if there was a way to force the resize of the containing panel without manually calling <code>Size</code>.</p>
  
  <p>I guess I'm looking for the inverse of the property <code>Dock=Fill</code>, which automatically resizes elements based on the size of their containing element.</p>
  
  <p>Thanks in advance.</p>