C# winform 画面最大化size设定

来源:互联网 发布:sql 身份证号与岁数 编辑:程序博客网 时间:2024/06/06 13:20

1.画面最大化时,画面的边框会不显示。然后在计算子画面的位置用主画面的size计算会有一定偏差。

我们可以在画面的构造函数中设定:this.MaximizedBounds =new  Rectangle(1, 1, SystemInformation.WorkingArea.Width, SystemInformation.WorkingArea.Height);

2.画面中使用一些插件,可能右边被占用,画面在Normal时可以和右边共存,可以最大化

可以在构造函数中写

 if (Common.Common_Func.pRegKey == 14 && scale >= 1.5)
            {
                if (frm.WindowState == FormWindowState.Maximized)
                {
                    frm.Size = new System.Drawing.Size(SystemInformation.WorkingArea.Width * 3 / 4, SystemInformation.WorkingArea.Height);
                }
            }

 

然后在画面Load中写

 if (Common.Common_Func.pRegKey == 14 && Common_Func.scale >= 1.5)
            {
                this.WindowState = System.Windows.Forms.FormWindowState.Normal;
            }

画面启动就不是最大化了。

 

原创粉丝点击