How to Get Width & Height of Desktop in WinForms
In certain scenarios we need to know the screen resolution our desktop application will be running on. To get this information, Microsoft provides us with a very handy class namely SystemInformation that can be found in System.Windows.Forms namespace. Using this class, we can almost every information about the current system environment, the application is running on.
To get the Height and Width of the Desktop screen, use the below 2 lines of code –
int height = SystemInformation.VirtualScreen.Height; int width = SystemInformation.VirtualScreen.Width;
Dim height as Integer = SystemInformation.VirtualScreen.Height Dim width as Integer = SystemInformation.VirtualScreen.Width
Hope you like this post! Cheers!