我在一个父窗体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,望高手指教,拜谢了!!
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,望高手指教,拜谢了!!
解决方案 »
- 读取EXCEL的某些列
- 求助:在线等 绑定Leave事件无法使用Tab失去焦点
- C# 读取数组元素
- C#中使用浮动工具栏(FloatingToolStrip)需要添加什么引用
- 为什么Form载入时datagridview.Currentrow==null?
- 新学习C#,有没有C#的MSN群?
- 请教?怎么用C#查找ACCESS数据库中的一段时间的数据
- oracle查询语句的问题?
- 究竟是什么地方出错了,为什么DataGrid老是显示初始化时的数据?烦死了!
- 想做个读取矢量图wmf的最简单小程序,如何作手啊?
- 关于ResourceHelper类的一个问题,,请高手帮忙
- 后台数据库和前台的DataGrid显示的数据同步
//你上面的代码实际上是new了一个新的窗体,实际上传入引用就可以了
cf.MdiParent=this.MdiParent;
cf.Show();
this.Close();