4
Answers

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

Rajkumar R

Rajkumar R

10y
8.4k
1
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 (4)