LayoutMdi fails in form's OnLoad event

前端 未结 2 1599
无人及你
无人及你 2020-12-20 05:32

Hello I have OnLoad eventhandler like this:

private void MainView_Load(object sender, EventArgs e)
{
    LayoutMdi(MdiLayout.TileVertical);
}
相关标签:
2条回答
  • 2020-12-20 06:20

    Either that or in the .MdiChildActivate() event handler of the MDI parent form:

    private void MDIParent_MdiChildActivate(object sender, EventArgs e)
    {
      this.LayoutMdi(MdiLayout.Cascade);
    }
    
    0 讨论(0)
  • 2020-12-20 06:28

    Yes, doesn't work. Probably because the child windows aren't visible yet. It works fine in the Shown event:

        protected override void OnShown(EventArgs e) {
            var f2 = new Form2();
            f2.MdiParent = this;
            f2.Show();
            f2 = new Form2();
            f2.MdiParent = this;
            f2.Show();
            this.LayoutMdi(MdiLayout.TileVertical);
        }
    
    0 讨论(0)
提交回复
热议问题