I want my winform app controls to be at a certain location and a certain size no matter what screen resolution the user is using.
Could someone give me a quick example of how to shape a panel to start at 60% down on the screen to 100% down on the screen, and to be the full length of the screen?
I hope that made sense, so basically no matter what the screen resolution is, the panel will take up 40% of the winform starting 60% down on the app.
Thanks!
I want the same % to be no matter if the resolution is 800X600 or 1024X760.
You can use SplitContainer, which divides the form into two areas. If you change it’s orientation to horizontal, you get 2 areas, one which starts on the top of the screen and the second on the other side. Now you can define minimal sizes of each of the panel:
This makes the top panel take 60% of the client area and the bottom 40% of it. It’ll automatically start 60% down on the form. Then you can put any other control you want into the panel and dock it to the panel using
Control.Dock = DockStyle.(something)The other way how to change the position of any control is to basically compute it’s position and size. You can get the width of the client area as
Form.ClientSize.Widthand the beginning X, Y position of the 60% down on the app as:Now you can set the control’s size and position as:
So if you’d like to force for example
label1inForm1to act like you wrote in your post, one possibility would be this: