简体   繁体   中英

MdiLayout not producing desired output

I have an MDI container which allows a user to choose whether to have the form's children tile or cascade when they open. The user can choose this option through by click and checking an item in the menu. However, after checking the item and opening the form, they appear on top of one another instead of tiling or cascading. I've tried to call the layout method after opening the form [after dlg.Show() in the methods below] but it still does not produce proper layout.

Any ideas?

Menu Event Handlers

private void titledToolStripMenuItem_Click(object sender, EventArgs e)
    {
        cascadingToolStripMenuItem.Checked = false;
        this.LayoutMdi(MdiLayout.TileHorizontal);
    }

    private void cascadingToolStripMenuItem_Click(object sender, EventArgs e)
    {
        titledToolStripMenuItem.Checked = false;
        this.LayoutMdi(MdiLayout.Cascade);
    }

Form Open method

private void openTallChildToolStripMenuItem_Click(object sender, EventArgs e)
    {
        TallChild dlg = new TallChild(this.height);
        dlg.MdiParent = this;
        dlg.Show();

    }

This can happen when the child's FormBorderStyle is not set to Sizable.

Try:

dlg.FormBorderStyle = FormBorderStyle.Sizable;

我不得不将this.LayoutMdi放到受保护的覆盖void OnShown中,以使布局正常工作https://stackoverflow.com/a/2836353/74585

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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