Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stuff in Windows Form Move When Maximized - C#

It's been a while since I've programmed a GUI program, so this may end up being super simple, but I can't find the solution anywhere online.

Basically my problem is that when I maximize my program, all the things inside of the window (buttons, textboxes, etc.) stay in the same position in the window, which results in a large blank area near the bottom and right side.

Is there a way of making the the elements in the program to stretch to scale?

like image 791
AlbertEngelB Avatar asked Sep 30 '08 18:09

AlbertEngelB


People also ask

How do I open windows form in maximized?

Desktop shortcut icon: Right-click the shortcut icon and select Properties from the drop-down menu that appears. Taskbar shortcut icon: Forcing these applications to open as maximized requires an additional step. Right-click the shortcut icon in the Windows taskbar, then right-click the program itself.

How do you remove minimize and maximize button in Windows form?

Minimize button enables users to minimize the window to the taskbar. To remove minimize button we have to set the MinimizeBox property to false of the windows form. Now when you open the windows form you will notice the windows form's minimize button is in disable mode in the windows form.

What is maximize box?

Maximize allows the user to enlarge a window, usually making it fill the entire screen or the program window where it is contained. When a window is maximized, it cannot be moved until it is reduced in size using the Restore button.


2 Answers

You want to check and properly set the Anchor and Dock properties on each control in the Form. The Anchor property on a control tells which sides of the form (top, bottom, left, right) the control is 'anchored' to. When the form is resized, the distance between the control and its anchors will stay the same. This lets you make a control stay in the bottom right corner for example.

The Dock property instructs the control to fill the entire parent form or to fill one side of it (again top, bottom, left or right).

like image 71
Brian Ensink Avatar answered Sep 27 '22 21:09

Brian Ensink


Anchor and Dock properties

like image 38
Steven A. Lowe Avatar answered Sep 27 '22 22:09

Steven A. Lowe