hi there!! i'm having problem with my winforms.

because when i run it at a different computer's resolution it doesn't look like the one i made.

like for example, i build it using a 1280X1024 hence it runs fine at using this resolution but when i run it on a 800X600, the forms is too big.

how could i make the forms cope up with the resolutions???

Recommended Answers

All 6 Replies

You have a Screen cass which exposes a property GetBounds.
You can use it to set the size of your form.

how can i do this??? is there a certain code for it??

I assume you are using C# 2008 VS express.
Then use this call :
Rectangle r = Screen.GetBounds(myform);
This does not give you the bounds of your form but it gives you the bounds of the screen your form wants to live in.
Now r contains all the elements to adjust the size of your form.

commented: Danny you're very nice, truly +6

I'm not using c# 2008 i'm using c# 2005 standard edition.

I used

this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;

the form was successfully changed according to the computer's resolution but the contents isn't. like the content was ruined

like when a button was supposed to be located at the down left corner of the form,it isn't displaying at its position anymore(can't see it)because of the high resolution(800X600 from 1280X1024).

how can i make the content fit the changed resolution?

Perhaps have a look at the Anchor property of your controls?
Or make your design fit for the lowest resolution. It makes no sense to have a screen 100 high 100 wide and have a button placed at location 1000,1000

This is really a question of layout more than resolution, the resolution is what causes the design error to manifest itself. Other settings such as enabling large font support cause a windows form to be drawn "bigger" than it normally would, for which there is no fix (because there shouldn't be).

What you can do is lay everything out in panels and dock them. Have the button that should be in the lower left in a panel that is docked to the right on the form, that way the main area of the application would appear shorter and get a scrollbar but the button would still be visible.

Anchoring is handy to guarantee a certain distance from the parent container, but the parent container should always be docked to assure its' visibility.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.