简体   繁体   English

C#WinForms MDI问题

[英]C# WinForms MDI problem

Hello guyes i have one problem i have 1 parent form and 3 children i just want to open them maximized but when i do that in left side comes this 3 controls. 大家好,我有一个问题,我有1个家长表格和3个孩子,我只想最大化地打开它们,但是当我在左侧进行操作时,就会出现这3个控件。 How can i open one form without this controls. 没有此控件,如何打开一种表单。 If im doing this with wrong way please advice me something does mdi good for such things? 如果我以错误的方式这样做,请告诉我某些东西对这种事情有好处吗?

please see this pictures http://img440.imageshack.us/img440/6831/mdinz.jpg http://img139.imageshack.us/img139/4687/mdi1.jpg 请参阅此图片http://img440.imageshack.us/img440/6831/mdinz.jpg http://img139.imageshack.us/img139/4687/mdi1.jpg

This is a known bug in the MDI implementation, triggered when you create a maximized child window in the parent constructor. 这是MDI实现中的一个已知错误,当​​您在父构造函数中创建最大化的子窗口时触发。 This is an example: 这是一个例子:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        var child = new Form2();
        child.MdiParent = this;
        child.WindowState = FormWindowState.Maximized;
        child.Show();
    }
}

You'll see the min/max/restore glyphs displayed twice, restoring the child window leaves the MDI bar on the screen, just as in your first screen shot. 您将看到两次显示的最小/最大/还原字形,还原子窗口将在屏幕上留下MDI栏,就像您在第一个屏幕截图中一样。 The workaround is to move the child creation code to the OnLoad() method. 解决方法是将子创建代码移动到OnLoad()方法。 Like this: 像这样:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
    }
    protected override void OnLoad(EventArgs e) {
        base.OnLoad(e);
        var child = new Form2();
        child.MdiParent = this;
        child.WindowState = FormWindowState.Maximized;
        child.Show();
    }
}

如果需要,可以使用ControlBox, FormBorderStyle, MaximizeBoxMinimizeBox属性从表单中删除各种窗口UI元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM