Bryan Brannon

I am trying to design a windows form application that responds well to clients on different resolutions. The application that I am developing needs to autofit based on the resolution on the client.

The question that I have is are there any good examples or howto's on the web or in books to explain this better. I would like to design a form that has user controls on it and have it size up or size down based on the client screen resolution.

For example, my development environment is 1680 x 1050. Do I need to create my form for that and set my AutoScaleMode to Dpi or Font The runtime application will need to run on 1920 x 1080 and even down to 1366 x 720 (all standard widescreen formats).

Any help getting started would be greatly appreciated.



Re: Windows Forms General AutoScaleMode Examples

Zamial

Can it be done as a web app instead

I find there much easier to manage the resizing issues.

Otherwise I don't know of any good guides for this i'm afraid

Most projects i've been on do not resize well at all.





Re: Windows Forms General AutoScaleMode Examples

Bryan Brannon

It is a web app now but for some specific reasons it now needs to be WinForms. Thanks for your comments, I will keep looking.





Re: Windows Forms General AutoScaleMode Examples

Fábio

You can use the Screen Size to be the base of your controls' sizes. Create a XFactor and YFactor variable to assing the sizes depending on the size of the screen. For instance:

Code Snippet

int FactorX = Screen.PrimaryScreen.WorkingArea.Width / 1000;

int FactorY = Screen.PrimaryScreen.WorkingArea.Height / 1000;

myButton.Width *= FactorX;

myButton.Height *= FactorY;

You should experiment with the numbers to get the desired effect. Make different divisions and multiplications to see which suits you better and which is better for different resolutions.

Hope this helps you getting started.






Re: Windows Forms General AutoScaleMode Examples

nobugz

First off, be sure to design your form starting with the smallest (1366 x 720) size. You can scale up but you can't scale down. You'll want to set AutoScaleMode to Font 99% of the time. Dpi is only useful if your form contains a lot of graphics that must be shown at the original physical size in inches. That's rarely important. Besides, when you increase the Dpi setting of your video adapter, you'll also get larger fonts.





Re: Windows Forms General AutoScaleMode Examples

Bryan Brannon

Okay,

So lets say i start off with 1366 x 720 form and set the AutoScaleMode to Font. Design my form so that everything looks correct and then when i run the application on a machine with lets say 1920 x 1080 it should look good

Do i need to do any coding to compensate for my displays





Re: Windows Forms General AutoScaleMode Examples

nobugz

That's not what AutoScaleMode is designed to do. It compensates for larger fonts, not larger displays. The best way to deal with higher screen resolutions is to use the Anchor and Dock properties and/or the TableLayoutPanel and FlowLayoutPanel classes for more advanced layouts.