父窗体与子窗体问题,Form.MdiParent 属性

来源:互联网 发布:剑网三捏脸数据下载 编辑:程序博客网 时间:2024/05/19 16:33


下面的代码示例演示如何在 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();
}

0 1
原创粉丝点击