Rajkumar R

Rajkumar R

  • NA
  • 183
  • 215.7k

How to get monitor width and height in C# windows app?

Sep 5 2014 2:04 AM
Hi,
 
My machine in windows-7 & Screen resolution is (1366 * 768) Highly recommended.
 
float height = SystemInformation.VirtualScreen.Height;
float width = SystemInformation.VirtualScreen.Width;
double diagonal = Math.Sqrt(width * width + height * height);  
 
The above code I have used to get width and height of the screen to calculate diagonal in windows application. But the problem here is when I change the resolution width and height also gets change. So I need a piece of code that should read height and weight to calculate diagonal size. 
 
Please post solution for this post.
Thanks in Advance. 

Answers (5)