2013-02-13 106 views
2

我在想,winform显示器能否找到并显示当前显示的当前屏幕分辨率?Winform显示屏分辨率

例如,如果我的屏幕是1920 x 1080,它会在标签或打印行中显示。虽然后半部分是我知道如何去做的。

请问有人请赐教,如果有可能为winform找到这些数据吗?

回答

9

使用Screen class

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

谢谢...从我这里还+1 – Sandy 2013-02-13 13:17:40

1

是的,当然,C#和WinForms能得到您的当前屏幕分辨率,试试这个代码

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

或者你可以尝试将其显示为一个标签或者作为一个消息

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