Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
4.29/5 (4 votes)
See more:
Hello,

I am working on a win form application.

I'm focusing more on User interface and I am facing some problems.

One big problem is of screen resolutions.
While devloping the project my computer's screen resolution in 1024 * 768.
When I change the screen resolution either minimum or maximum my win form application screens designs are getting disturbed.

I am trying to adjust win form screens according to screen resolutions.

How to do this?

Please help
Posted
Updated 29-Mar-11 6:59am
v2
Comments
Dalek Dave 29-Mar-11 12:59pm    
Edited for Grammar and Readability.

You can adjust your control's Dock properties, this properties can adjust probably most of controls(eg DataGridView,Panel,Label(use as Header)).But this properties can't adjust all of controls.

Best Regard,
Theingi Win
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Mar-11 11:38am    
This is just one of the aspect. Please see my Answer as well.
--SA
Dalek Dave 29-Mar-11 13:01pm    
This is true
This is very difficult, if not impossible to do in WinForms: easy in WPF.

You can use the Anchor property to expand and contract controls, but except in simple forms that isn't going to help much. The only way to do it "nicely" is to use edge located frames around a single inner core, in the same way as Visual Studio does - and probably for just that reason!

Sorry, but them's the breaks!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Mar-11 11:35am    
Anchor is bad, but all can be done with docking. "Very difficlut, if not impossible" compared to WPF is the exaggeration. I'm sure everything you can do of WPF about flexible layout I can reproduce with Forms.
--SA
Member 10829832 23-May-14 15:10pm    
Check this DUDE
Paste This In Form Load
this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

M.S Technologies
Make a eventhandler to the resize event (properties window > events or this.Resize += new EventHandler(somefunction);) then resize/reposition all controls on your form using the new dimentions found in this.ClientRectangle.

example:

C#
private void PersonalizeColumnsForm_Resize(object sender, EventArgs e)
{
    listColumns.Top = 10;
    listColumns.Left = 10;
    listColumns.Height = this.ClientRectangle.Height - 20;
    listColumns.Width = this.ClientRectangle.Width - 30 - btnClose.Width;

    btnClose.Left = 10 + listColumns.Width + 10;
    btnClose.Top = 10;

    btnCheckAll.Left = btnClose.Left;
    btnCheckAll.Top = btnClose.Bottom + 10;

    btnUncheckAll.Left = btnClose.Left;
    btnUncheckAll.Top = btnCheckAll.Bottom + 10;

    btnTop.Left = btnClose.Left;
    btnTop.Top = 20 + (listColumns.Height / 2) - 35 - btnUp.Height;

    btnUp.Left = btnClose.Left;
    btnUp.Top = 20 + (listColumns.Height / 2) - 5 - btnUp.Height;

    btnDown.Left = btnClose.Left;
    btnDown.Top = 20 + (listColumns.Height / 2) + 5 + btnDown.Height;

    btnBottom.Left = btnClose.Left;
    btnBottom.Top = 20 + (listColumns.Height / 2) + 35 + btnDown.Height;

    btnReset.Left = btnClose.Left;
    btnReset.Top = listColumns.Bottom - btnReset.Height;
}
 
Share this answer
 
v3
Comments
willempipi 29-Mar-11 10:22am    
Score of 1???

Nice guys, I'm only trying to help, and my answer is not wrong...

Thanks!
#realJSOP 29-Mar-11 11:50am    
It's not necessarily wrong, but you don't have to do this because you can set all that in the properties in the designer. You don't HAVE to handle the resize event. I'm gonna vote your answer a 5 to compemnsate because I hate it when people 1-vote my answers just because they're not the answer they're looking for and regardless of how correct the answer is.
willempipi 29-Mar-11 11:59am    
Thanks John!
Dalek Dave 29-Mar-11 13:00pm    
5 for the effort that was downvoted incorrectly.
Put a TableLayoutPanel on your Form. Then put your controls in the cells of the TableLayoutPanel. Combine with control's Dock property.
 
Share this answer
 
Comments
Dalek Dave 29-Mar-11 13:01pm    
Agreed.
You need to do you layout resolution-tolerant.

Please see my recommendations here:
Zom Out malfunctions when Screen resolution changes[^]

Some more general ideas:
GUI Apperance - C#.Net[^]

—SA
 
Share this answer
 
You can set your anchors on the controls, and make it fairly resilient, but you MUST decided on a minimum width/height for the form. I think 1024x768 is a more-than-acceptable minimum.
 
Share this answer
 
You can set your anchors on the controls, and make it fairly resilient, but you MUST
 
Share this answer
 
Comments
[no name] 22-Aug-13 21:00pm    
Copying someone else's answer to pass it off as your own is so not cool. And we won't even talk about being so lazy as to not even bother copying the entire 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