There's a complete working WinForms example of a Collapsible UserControl (source and .exe files) here: [
^].
This Project is compiled against .NET 3.0.
It demonstrates the UserControl resizing itself as a Panel at the bottom is made visible, or hidden by the user at run-time. It demonstrates control of the UserControl Panel visibility both from the Form it is sited in, and from
within the UserControl.
It also demonstrates taking into account the need to adjust the UserControl when it's changed so that the Padding factor of the UserControl is taken into account, and the UserControl maintains a consistent "virtual border."
If my assumptions about your goal (expressed in my comment to your OP) are correct, creating a collapsible UserControl (or Panel), where one ContainerControl is made visible, or is hidden, and the UserControl/Panel resizes itself to fit the current contents ... is something I have done frequently.
imho, easy ... once you've done it once :) I have been meaning to write this up for CodeProject, so, this is kind of the "first draft."
Unfortunately, there are real problems with the AutoSize Property of both UserControls and ContainerControls, like Panels, in WinForms: once you have Controls sited within these containers that are Docked, you are going to have problems at run-time. If you thought you could use AutoSize, forget it.
The only alternative
I know of is the kind demonstrated in this example.
Happy Holidays !
Disclaimer: This code example is provided for educational purposes only; I make no commitment to fix/improve/maintain the code
as it is now. Of course, I welcome any bug-reports. At the point this is turned into a CP article, or Tip/Trick, I will support the code.