C#设置窗体最大化示例:
也可将方法内的内容放到主窗体首次加载load方法中。
/// <summary>
/// 设置窗体最大化(不遮挡任务栏)但此方法在宽屏中不能显示全屏
/// </summary>
/// <param name="frm"></param>
public virtual void SetFormMax(Form frm)
{
frm.Top = 0;
frm.Left = 0;
frm.Width = Screen.PrimaryScreen.WorkingArea.Width;
frm.Height = Screen.PrimaryScreen.WorkingArea.Height;
}
/// <summary>
/// 设置窗体最大化(不遮挡任务栏)显示全屏
/// </summary>
/// <param name="frm"></param>
public virtual void SetFormMax(Form frm)
{
this.MaximumSize = new System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width + 10, Screen.PrimaryScreen.WorkingArea.Height + 1);
}