2013-02-13 107 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();