kevin628
kevin628

Reputation: 3526

Resolution of the current monitor

How does one get the screen resolution of the current monitor? By "current monitor", I mean the one that the application starts on.

The reason I ask this is because I have two monitors, the secondary monitor is 1280x1024 and the primary is 1680x1050. The application, when it starts, stupidly sets its own height and width based on the primary monitor resolution. When the application launches on the secondary monitor, it overflows the resolution, which looks strange.

I know I could change/remove the code that sets the application's height/width, but I am also curious how one determines which monitor the application is showing on.

For what it's worth, I am not a proponent of applications that set their own height/width.

Upvotes: 5

Views: 791

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55354

Use Screen.FromControl:

Screen.FromControl(this).Bounds

where this is the Form that you want to retrieve the Screen information for.

Upvotes: 8

Related Questions