William Thompson

William Thompson

  • 1.6k
  • 155
  • 299k

Dynamic Resizing of Form Elements Relative to Form Shape in C#

Apr 19 2010 2:13 AM


What is the magic that makes components cling to the edges of a form?
I had thought that one must use the resize event of the form and them force each element in the form to resize.

But then I saw some sample code which, even when I am editing the form, the elements seem to adhere to a percentage of the space they take up in the form rather than a set diminsion.  In other words, when I am editing the form and resizing it, the panels and the parts inside the form bend their shape such that the edges remain a few pixels from the edges.

But in my own program I have not been able to find where I can duplicate this feature.  When I run my program, this ([URL=http://i67.photobucket.com/albums/h292/Athono/microsoft/001.jpg]normal looking form/window[/URL]) goes to this ([URL=http://i67.photobucket.com/albums/h292/Athono/microsoft/002.jpg]expanded window/form with the components staying put when I want them to resize[/URL]) when I click on the bottom right corner of the window and drag the mouse to resize.