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 (http://i67.photobucket.com/albums/h2...rosoft/001.jpg) goes to this (http://i67.photobucket.com/albums/h2...rosoft/002.jpg) when I click on the bottom right corner of the window and drag the mouse to resize.