我有没有border的自定义窗体。我在子窗体上应用该自定义窗体。我有自定义MDIParent表格,也没有边框。那么,我的问题是当我最大化子窗体然后顶部边框出现在MDIForm的一侧时所以如何使用c#来管理或解决这个问题。See my snapshot for more detail of my problem我想从自定义MDIForm顶部删除带有最大化按钮的边框
答案 0 :(得分:-1)
我不确定你是如何调用子表格的,但这是一个例子:
private void Button1_Click(object sender, EventArgs e)
{
var myForm = new MyCustomForm();
myForm.MdiParent = this;
myForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //this should hide the border even when it is maximized.
myForm.Show();
}
或者,您可以捕捉“最大化”'事件并使用您自己的方法覆盖它,再次确保没有边框:
private void MaximizeWindow()
{
var rectangle = Screen.FromControl(this).Bounds;
this.FormBorderStyle = FormBorderStyle.None;
Size = new Size(rectangle.Width, rectangle.Height);
Location = new Point(0, 0);
Rectangle workingRectangle = Screen.PrimaryScreen.WorkingArea;
this.Size = new Size(workingRectangle.Width, workingRectangle.Height);
}
并捕获最大化事件:
private void Form1_Resize (object sender, EventArgs e)
{
if (Form1.WindowState == FormWindowState.Maximized)
{
// Do some stuff
}
}
来源:
- How to show a child form within a mdi container form which its windowstate= maximized?