如何点击(不按尺寸,如何使表格填满整个屏幕)全屏显示,例如f11
)。在设计时-时间(后面没有代码)?
在设计时,使用定义为Maximized
的WindowsState属性。
在运行时,您可以使用此:
static public class FormHelper
{
static public void SetSizeToScreen(this Form form)
{
int left = Screen.PrimaryScreen.Bounds.Left;
int top = Screen.PrimaryScreen.Bounds.Top;
int width = Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Height;
form.Location = new Point(left, top);
form.Size = new Size(width, height);
}
static public void SetSizeToDesktop(this Form form)
{
int left = SystemInformation.WorkingArea.Left;
int top = SystemInformation.WorkingArea.Top;
int width = SystemInformation.WorkingArea.Width;
int height = SystemInformation.WorkingArea.Height;
form.Location = new Point(left, top);
form.Size = new Size(width, height);
}
}
用法:
this.SetSizeToDesktop();