Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i am developing window application(C#2.0).I want resize my projects screen based on screen resolution.screen should be show as full screen and controls size also increse/decrese while i change screen resolution.
Updated 25-Feb-10 1:48am

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.

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.
Share this answer
You could just maximise your form:

myForm.WindowState = FormWindowState.Maximized;

Share this answer
Found a post related to this on CP here[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900