简体   繁体   English

检查MDIcontainer是否为空

[英]check whether the MDIcontainer is empty or not

I just stuck in a very simple situation bt couldnt help myself.My question is How to do i check whether my mdiparent contains the child form or not? 我只是陷入一个非常简单的情况,bt无法帮助自己。我的问题是如何检查我的mdiparent是否包含子表格? help will be appreciated. 帮助将不胜感激。

You can use the ActiveMdiChild property of your parent form. 您可以使用父窗体的ActiveMdiChild属性。

It will be null if the parent does not contain any MDI child form. 如果父级不包含任何MDI子窗体,则它将为null

For the title of your question: 对于您的问题的标题:

int formCount = this.MdiChildren.Count(); \\ or .Length
MessageBox.Show("I have " + formCount.ToString() + " child forms open.");

For the other part of your question: 对于您问题的另一部分:

Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();

if (this.MdiChildren.Contains(f2))
  MessageBox.Show("Form2 f2 is opened");

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

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