Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I am creating Windows form 1280×800 working good .
But if I am install my application into another pc (client) then screen resolution not show right .. many controls cut out .

[Help]

Any suggestions .. what's best screen resolution size ?

What I have tried:

Any suggestions .. what's best screen resolution size ?
Posted
Updated 22-Jul-19 18:12pm

In WPF add these attributes to your Window element:

WindowStartupLocation="CenterScreen" WindowState="Maximized"

In WinForms, put this in the constructor AFTER the call to InitializeComponent()

this.WindowState = FormWindowState.Maximized;

BTW, these are easily discovered with even the most rudimentary of google searches.
 
Share this answer
 
v2
Comments
BillWoodruff 22-Jul-19 20:38pm    
I don't think the OP here is asking how you completely fill the Screen with the Form.
A simple way to scale your Winform in C#:
// Scale form, AutoScaleMode.Font must be set for this to work.
this.Font = new Font(this.Font.Name, this.Font.Size + 2);
Note that this won't work for some complicated controls.
Also see example here: RoundedButton Control - Demystifying DrawArc[^]
 
Share this answer
 
Comments
BillWoodruff 22-Jul-19 20:56pm    
interesting, this would result in the Form getting wider, taller; however, the fact this won't play nicely with the ContainerControls most useful for building tightly architected resizable Forms rules it out ... for me. I'll have to go look to see what happens with 'FlowLayOutPanel.
Please clarify if this is about WinForms.

There is no "magic bullet" that will guarantee your Form, and the Controls in it, will look the same on every type of device of whatever screen size and resolution.

WPF, in which all UI elements are vector based, will, in theory, give you a Form that looks the same at any scale.

In practice, Fonts, even though they are based on vectors, are "hinted" internally: when rendered at certain sizes, they will appear slightly different. That's done for readability at the "standard" sizes (less than 14~18 points) most apps use for text.

... in WinForms

Make use of setting the Form MinimumSize and MaximumSize Prop(rties to constrain the sizes which the user can resize the Form to by direct action (dragging) at run-time.

In WinForms, the key thing you can do is to make careful use of ContainerControls with their Docking properties set, and, for the Controls inside these ContainerControls, use the Dock, or Anchor, Properties to control what happens when the Form is resized.

For ContainerControls, you can affect internal appearance (visible margin) by setting the Padding Property; with undocked Controls, setting Margin Property can affect their spatial relation-to/separation-from other Controls.

You can experiment with WinForm AutoScale, AutoScaleMode, and Autosize properties, as well as StartPosition.

Of course, you can also set WindowState: I recommend you only use WindowState.Maximized when you are certain you want to fill the user's entire screen. Do you really want to hide any Toolbars the user has set to stay open ?

Finally, the TableLayoutPanel, and FlowLayoutPanel, are complex and powerful layout design ContainerControls ]: it will take some effort to learn how to use them. imho, well worth investing in learning to use them.
 
Share this answer
 
v4

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