Anchor property window form is for the alignment of form components in the window. It allows us to position the window components (text box, button, grid, etc.) according to our requirement.
I have a window form application that is used in my previous blog “How to establish database connection with MySQL in C# through App.config”, let’s use it.
First put some form component from toolbox.
Now run the application and resize or maximize the window and see what happens.
After resize:
To use anchor property select the component and go to property. Under layout there is Anchor = Top, Left. Change these positions according to your requirement.
By default it set to Top, Left. And in property it looks like this.
To align the component to Bottom, Right of the window, select bottom and right sides.
Run the project again and see the changes are working or not.
Normal state:
After resize: