开发者

Conflict with MDI and SplitContainer

开发者 https://www.devze.com 2023-04-12 02:57 出处:网络
I am using a SplitContainer to split a MDI form vertically. On the left panel I have a tree control and on the right panel I am displaying the child forms. I am trying to ensure only a single instance

I am using a SplitContainer to split a MDI form vertically. On the left panel I have a tree control and on the right panel I am displaying the child forms. I am trying to ensure only a single instance of a child form is open at any time. To do that I am checking the MdiChildren count. However, the mdi children count is resetting to zero开发者_运维知识库 after I add the child form to the right panel of the split container.

subjectForm.MdiParent = this;
Console.WriteLine("B => " + this.MdiChildren.Length);
this.splitContainer1.Panel2.Controls.Add(subjectForm);
Console.WriteLine("A => " + this.MdiChildren.Length);

In the above code sample, this is the response I am getting

B => 1; A => 0

Any idea where I am going wrong ?


After spending long hours trying to work with the SplitContainer, I replaced it with a splitter and things are working as expected. However, I am still not sure about the utility or need for the split container control.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号