Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello guys! i want to know how to fit c# application in every Resolution my c# application open in my computer is perfect but when i install this application on my client machine so it's show half application.

What I have tried:

this.WindowState = FormWindowState.Maximized;
this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
Posted
Updated 25-Jul-16 13:44pm
v2
Comments
Philippe Mori 25-Jul-16 14:07pm    
You should always design form so that it fit the desired minimum size (say 1000x700 with 100% font scaling).

And then you should uses anchors, docking or some layout controls to adjust the size of some controls that could benefit of additional available space.

Typically scaling should be based on font size for most application.

The trouble is that you've designed it to fit a single resolution - your screen - and the user doesn't have that large a display. While it's possible to make controls grow and shrink automatically in WinForms via the Anchor and Dock properties, it generally isn't very successful on a large scale change because although the controls themselves change size the text inside them doesn't - so you end up in your case with smaller buttons that the text no longer fits onto.

I'm sorry to say that unless you design your app from the beginning to support wildly different screen sizes there isn't much you can do automatically to support it. And designing your app to work means doing something like Visual Studio does: dockable "tool panels" around the outside of a larger central working area. If you have just filled the display with controls you probably have a major redesign on your hands.
 
Share this answer
 
Comments
Member 9983063 25-Jul-16 15:42pm    
Sir is it possible if my client screen resolution is 1920*1080 like my screen resolution so my application fit perfect
If your screen resolution is the same as your client's, and you are both using monitors with the same standard aspect ratio (typically, today, 16:9 for desktop monitors) ... the client should have no problem.

Welcome to the great puzzle of dealing with different display device sizes, screen resolutions, and aspect ratios: [^].

An example of how it gets complex: the screen resolution I use ... because of vision problems I need to see things BIG ... is 1360/768 (ratio 683:384) which does not map exactly to 16:9 or 16:10 ... or 4:3. The reasons for this resolution becoming frequently used some years ago involved manufacturing efficiency, computational efficiency, 8-bit screen memory device limitations, and consumer demand for wider screens than 1024/768 provided.

I suggest you consider it part of your application design to research the possible future use of your application on devices with different form-factors and screen-display characteristics.

In dealing with the client, I suggest you make it part of your contractual agreement that you specify the different monitor screen ratios the UI is designed for, and whether the app can be used if the monitor is in "portrait" rather than "landscape" orientation.

If you use WPF, you have the benefit of a completely vector-based graphic engine ... however, that does not guarantee your app will look "perfect" at any arbitrary size ! Windows Forms's GDI+ graphics engine is much more limited.

In any case, fonts in smaller sizes than #14 are always going to look best at certain discrete sizes; that's because they are "hinted" so that pixel adjustments are made to optimize screen readability. Trying to scale Fonts is not a good idea. So, for fonts at small sizes, you need to identify those discrete sizes and "jump" between them, rather than scale.

Observe what happens when, in a WinForms project, you select a Form and set its 'Font property to Consolas #10 ... in the Designer.cs file, you'll see this:
C#
this.Font = new System.Drawing.Font("Consolas", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
If you had chosen Consolas #9, the value would be #9; that value of #10.2 is the result of Windows looking up the optimum size at which hinting will be most effective.

I'd at least consider trying to make effective UI appearance at 1024x768, 1360x768, and 1920x1080.

And, certainly, study and try the other ideas in the solutions/comments offered to you here by OriginalGriff and Phillippe Mori !

I suggest you get familiar with these different Areas/Bounds properties of the WinForm app and Form:
C#
private Rectangle 
    screenBounds,
    screenWorkingArea,

    formDesktopBounds,
    formBounds,
    formClient,
    formDisplay;

private GetScreenFormInfo()
{
    var priScreen = Screen.PrimaryScreen;

    screenBounds = priScreen.Bounds;
    screenWorkingArea = priScreen.WorkingArea;

    formBounds = Bounds;
    formDesktopBounds = DesktopBounds;
    formClient = ClientRectangle;
    formDisplay = DisplayRectangle;
}
 
Share this answer
 
v3
Comments
Member 9983063 25-Jul-16 20:46pm    
how can i getscreenforminfo()?
BillWoodruff 25-Jul-16 21:05pm    
Use the code example shown in this solution; put it in a test project, run it. Call the method

Now examine examine the values of the different 'Rectangle fields.

Think about what the differences (or lack of differences) between these values MEANS, and then start planning on how to use that MEANING.

Keep in mind that the general problem of how to get the UI to appear in usable form on different screen resolutions ... is complex, and compromises will have to be made (usually).
There are solutions, but only commecial ones as far as I'm aware. Take a look at Larcom and Young Resizer[^]. The blurb says it's VB.Net only but it works for any .Net language. We used to use it in a previous company for EPOS interfaces & it worked well.
 
Share this answer
 
Comments
Member 9983063 25-Jul-16 15:42pm    
Sir is it possible if my client screen resolution is 1920*1080 like my screen resolution so my application fit perfect

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