如何获取我的表单所在屏幕的当前屏幕分辨率?
我已经尝试过使用primaryScreen,但它不能一直工作。
this.Size = new Size(Math.Min(width + 19, Screen.PrimaryScreen.WorkingArea.Width), Math.Min(height + dgvActualizar.ColumnHeadersHeight + 40, Screen.PrimaryScreen.WorkingArea.Height));
答案 0 :(得分:4)
您可能正在寻找FromControl
方法:
Screen screenFormIsOn = Screen.FromControl(this);
var width = screenFormIsOn.WorkingArea.Width;
var height = screenFormIsOn.WorkingArea.Height;
Screen.FromControl
应该返回加载表单的屏幕。
答案 1 :(得分:2)
请参阅屏幕类的以下文档:
http://msdn.microsoft.com/en-us/library/e8xzhd15.aspx
Screen current = Screen.FromControl(this);
Rectangle area = current.WorkingArea;
然后你可以
area.Width
和
area.Height.