How to set panel to automatically size itself to fit its contents

Demonstrate how to automatically resize panel to fit its contents. The app contains panel with enable AutoSize property and 'Add Button to Panel' button that adds button to the Panel. When you click on the button you will see that a button will be to the Panel and when added button is place outside of the panel, size of panel will be increased.

Zip package for C# download file
Zip package for VB.NET download file
File name: AutoSizePage_KB001download file
File name: AutoSizePage.csdownload file
File name: AutoSizePage.vbdownload file
File name: AutoSizePage.designer.csdownload file
File name: AutoSizePage.designer.vbdownload file
File name: AutoSizePage.resxdownload file