Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,

I am developing a desktop application using visual studio 2008. I have some forms without border. i add some picturebox, button and label in my form. I want to adjust form size (also corresponding control size) according to different screen resolution (Screen ratio 3:2, 4:3, 5:3, 5:4, 8:5, 16:9 and 17:9) . how it can be done. Please help me.

Thank you in advance
Posted
Comments
Ravi Sant 4-Jun-12 5:24am    
some helpful read: http://www.vcskicks.com/maintain-aspect-ratio.php
sswapniljadhav 25-May-18 7:20am    
Table layout might be helpful for you in windows forms, If you have choice in selecting technology then go for WPF application, WPF is more flexible.

In practice it isn't advisable - it doesn't normally present a good interface if you do, unless you put a lot of work into it yourself. For example, it is easy to get buttons to resize to fit the form, but the font size used for the button caption doesn't rescale with the button, so you end up with a large button, with tiny text in the middle, or a small button, with a single character displaying.

If you need to do this, then you need to move from standard WinForms to WPF - it can handle it very nicely!
 
Share this answer
 
Comments
Aravindba 18-Mar-14 2:55am    
Hai is it possible to move controls based on background images in WPF ? Actually what i did now ,i will declare only 2 resolutions to customer,if user try to open in other resolution it will show message,i will design one(1024X768) resolution and store x and y axis for controls and store in databse with unique id as resolution and design second(1280X1024) resolution and store x and y axis for controls and store in database with unique id as resolution.if user open 1024x768 then it retrieve x and y axis and send to controls top and height properties same as second resolution .bcz i have background image for whole form and based on that image i need to fix button on its place ,so once form is minimize or maximize or open in different resolutions is it possible to fix buttons on its place based on background image ? bcz in background image i will specify the place where to be button need to fix ,is it any way ? or need to capture x and y axis in database and retrieve x and y axis and append in controls top and height?

If it is not based on background image ,then ok dock or anchor property,pls reply me
OriginalGriff 18-Mar-14 6:00am    
If you have two "fixed" resolutions, then the way I would do it is to have two separate forms:
put all the processing code in a third class and create two separate forms. Then decide in program.cs which resolution to use and display the appropriate form.

That way, you can do the design of each form separately and easily because you can see what you are doing and where each control is going.
Use Dock and Anchor properties. Below is a good article. Note that these will handle changes when maximizing/minimizing. That is a little different that if the screen resolution changes, but it will be along the same idea.

http://www.techrepublic.com/article/manage-winform-controls-using-the-anchor-and-dock-properties/#.
 
Share this answer
 
Comments
johannesnestler 28-May-18 9:45am    
I don't know who downvoted your "solution" but this is also in my opinion the way to go. I did a lot of windows-forms programming back then (also with VS 2005-2008) and the "scaling" idea sometimes came up (from less experienced developers). A dynamic layout (as you recommendet) is the way to go - all other "automatic" scaling is a nightmare to use and test and dosn't provide the results you need (in WPF this is another Story because of Vector graphics - so such scaling is more likely to work - but even with WPF it's not a good idea… differnet aspect ratio will always be a trade-off - screenspace will be wasted)
Here an old similar nice question with answers

How to adjust screen of win form application According to System Resolution[^]
 
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