2012-06-22 92 views

回答

2

您可以使用父窗體的ActiveMdiChild屬性。

如果父代不包含任何MDI子窗體,它將是null

1

對於你的問題的標題:

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

對於你的問題的另一部分:

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

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