我在一个父窗体MDIform里加入了一个菜单,响应单击事件为:
private void menuItem1_Click(object sender, System.EventArgs e)
{
if (this.ActiveMdiChild!=null)
{
this.ActiveMdiChild.Close(); 
}
childForm1 child1=new childForm1();
child1.MdiParent=this
child1.Show();
}private void menuItem2_Click(object sender, System.EventArgs e)
{
if (this.ActiveMdiChild!=null)
{
this.ActiveMdiChild.Close(); 
}
childForm2 child2=new childForm2();
child2.MdiParent=this;       
child2.Show();
}同时,我在childForm1窗体中放置一个按钮,希望通过单击能打开另一个子窗体childForm2,同时关闭childForm1。
不知道有没有办法显示childForm2到主窗体并关闭childForm1;或者是有方法在childForm1可以调用主窗体中的menuItem2_Click事件,多谢了。我试过在childForm1中响应事件:
childForm2 cf=new childForm2();
MDIForm mdifrm=new MDIForm();
cf.MdiParent=mdifrm;
cf.Show();
this.Close();
但不行,只会关闭childForm1,但不会打开childForm2,望高手指教,拜谢了!!