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 (normal looking form/window) goes to this (expanded window/form with the components staying put when I want them to resize) when I click on the bottom right corner of the window and drag the mouse to resize.

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

You can use Anchor and Doc property.