Skip to content

Auto set screen resolution dynamically

Kanhialal kk

Asked Feb 29, 2012, 8:45 PM EST2 answers
Share
LinkedInX
How can I change the size of the forms in my Windows application when the
screen resolution the user has is higher than the one I developed the
application in? I have a customer that has a screen resolution of 1600x1200
and I developed the application in a PC with 1024x768 resolution. Is it
possible to increase the forms' sizes accordingly?

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    You can use this following C# statements to get the width and height of the screen. Based on available screen you can set your forms..

     
    int wid = System.Windows.Forms.Screen.GetBounds().Width;
    int height = System.Windows.Forms.Screen.GetBounds().Height;
    0
  • 0
    you can use the static class Screen to autofit your application to the current screen resolution.

    private void AutoFitToScreen()
    {
    Java
    // Retrieve the working rectangle from the Screen class
    // using the PrimaryScreen and the WorkingArea properties.
    System.Drawing.Rectangle workingRectangle =
    Screen.PrimaryScreen.WorkingArea;
    
    
    
    
    int newHeight = workingRectangle.Height;
    int newWidth = workingRectangle.Width;
    }
    0