You'll first have to figure out the ratios of the control size to form size along with how the location will change. Once you've done that, you can use the
Screen
class in
System.Windows.Forms
.
The members for that class can be found at:
Screen Members[
^]
The
PrimaryScreen
property is probably the one you'll want.
Then, you just adjust the sizes based on the ratios you've previously established. You'll probably also have to change the font size.
It's also a little tricky because the
FormBorderStyle
affects the height and width of the usable part of the form...the part where you can put controls. To see that, create a normal form that is 300x300. Now, change
FormBorderStyle
to None and the size changes to 292x266, so you actually have to use the
ClientSize
.
Example:
Let's say you have a form with a single button on it. When you design your form, it has a
Size
of 300x300 pixels. Your button's initial
Size
is 150x30. The
ClientSize
is 292x266. So,
button1HeightRatio = 150/292 = 0.5136
button1WidthRatio = 30/266 = 0.1128
And let's say your button's starting location is 44,49.
button1xRatio = 44/292 = 0.1507
button1yRatio = 49/266 = 0.1842
So, create variables to store those ratios, calculate them on Form_Load and update them on Form_Resize.