下面的代码示例演示如何在 MDI 应用程序中创建子窗体。 示例代码使用唯一的文本来确定子窗体创建一个窗体。 该示例使用 MdiParent 属性来指定窗体是子窗体。 此示例需要在示例中的代码称为从窗体具有其 IsMdiContainer 属性设置为 true 和窗体具有名为的私有类级别的整型变量
private void CreateMyChildForm ()
{
// Create a new form to represent the child form.
Form child = new Form();
// Increment the private child count.
childCount++;
// Set the text of the child form using the count of child forms.
String formText = "Child " + childCount;
child.Text = formText;
// Make the new form a child form.
child.MdiParent = this;
// Display the child form.
child.Show();
}

这段代码展示了如何在MDI(多文档界面)应用程序中创建子窗体。通过设置Form的MdiParent属性,将窗体指定为子窗体,并利用IsMdiContainer属性为true的父窗体。代码示例中,每次创建子窗体时,会更新其文本并显示。
1241

被折叠的 条评论
为什么被折叠?



