本文介绍了MdiContainer形式没有开放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个名为'mdfi'和'form1'的表单,我希望通过'form1'中的代码将'mdfi'表单设为MdiContainer我尝试了很多代码,但程序在运行时关闭了。这里的代码正在尝试



private void Form1_Deactivate(object sender,EventArgs e)

{

这个。 TopMost = false;

Mdfi newMDIChild = new Mdfi();

newMDIChild.IsMdiContainer = true;

this.MdiParent = newMDIChild;

newMDIChild.Show();

I've 2 forms named as 'mdfi' & 'form1',i want to make 'mdfi' form as MdiContainer by code from 'form1' i tried a lot do with this code but the programs close when i run. Here the code am trying

private void Form1_Deactivate(object sender, EventArgs e)
{
this.TopMost = false;
Mdfi newMDIChild = new Mdfi();
newMDIChild.IsMdiContainer = true;
this.MdiParent = newMDIChild;
newMDIChild.Show();

推荐答案

private void buttonFormActivator_Click(object sender, EventArgs e)
{
    //Create parent and child forms    
    Form MyMdiParentForm = new Form();
    Form MyNewMdiChildForm = new Form();

    //Make Parent form an MDI container
    MyMdiParentForm.IsMdiContainer = true;
    // Set the Parent Form as the parent of the Child Form.
    MyNewMdiChildForm.MdiParent = MyMdiParentForm;
    //Display the Parent form
    MyMdiParentForm.Show();
    // Display the child form.
    MyNewMdiChildForm.Show();

    // Hide your initial form, 
    // take care to write a method
    // to close this form when you are
    // done with the application. (Like a while app active loop)
    this.Hide();
}


这篇关于MdiContainer形式没有开放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 20:56