N0xus
N0xus

Reputation: 2724

Winform show screen resolution

I'm wondering is it possible for a winform display to find and display the current screen resolution that it is currently displayed on?

For example, if my screen is 1920 x 1080 it would show this in a label or a print line. Though the latter part is something I know how to do already.

Could someone please enlighten me to if it is possible for a winform to find this data please?

Upvotes: 2

Views: 5478

Answers (2)

Steve
Steve

Reputation: 216293

Use the Screen class

 label1.Text = string.Format("Primary screen size = {0}x{1}", 
               Screen.PrimaryScreen.Bounds.Width, 
               Screen.PrimaryScreen.Bounds.Height);

Upvotes: 10

fibertech
fibertech

Reputation: 357

Yes, of course, c# and WinForms can get your current screen resolution, try this code

Rectangle resolution = Screen.PrimaryScreen.Bounds;
int w = resolution.Width;
int h = resolution.Height;

Or you can try to show it as a label or as a messagebox

label1.Text = Screen.PrimaryScreen.Bounds.Width.ToString() + "x" + Screen.PrimaryScreen.Bounds.Height.ToString();

Upvotes: 1

Related Questions