如何查找窗体,来判断该窗体已经存在? 你把你的frmJys写成静态类,每次只实例化一次就行了。在CSDN中查查实例化一次有好多这方面的答案的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 foreach(control obj in this.pnBack.Controls){ if(obj.GetType()==typeof(frmJys)) { return; }}frmJys frmJys = new frmJys();frmJys.TopLevel = false;frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中frmJys.Show(); foreach(Control obj in this.pnBack.Controls) //Control第一个字母大写{ if(obj.GetType()==typeof(frmJys)) { return; }}frmJys frmJys = new frmJys();frmJys.TopLevel = false;frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中frmJys.Show(); 这样做当然是每次都是新窗体了,你可以:Form newForm;foreach(Form from in this.MdiChildren){ if(from.Name == "") { newForm = from; break; }}if(null == newForm){ newForm = new Form();} if(from.Name == "你窗体的类名") ====frmJys====public static bool IsOpen=false;=============if(! frmJys.IsOpen){ frmJys frmJys = new frmJys(); frmJys.TopLevel = false; frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中 frmJys.Show(); frmJys.IsOpen=true;} 你的代码,每次的form都是新的,form变量的定义你不要放在这里地方.至于你想要的效果,住高楼上的朋友都解答的好 嵌入VS2008开发环境 请教高手如何动态通知当前程序运行的状态。。。 这句VB.net怎么转换成C#的? TabControl控件的每个标签有什么不同吗? dllimport调用动态参数为名的dll?? combox问题 [分享]千万数量级分页存储过程(带效果演示) 为什么web浏览器在MDI窗体下不能用 ? 救救我啊,为什么写一个图片到数据库就这么难???? 在c#中如何制作dll文件,给powerbuilder调用? 一个问题 请教达人 关于dataset读取数据的问题
{
if(obj.GetType()==typeof(frmJys))
{
return;
}
}frmJys frmJys = new frmJys();
frmJys.TopLevel = false;
frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
frmJys.Show();
{
if(obj.GetType()==typeof(frmJys))
{
return;
}
}frmJys frmJys = new frmJys();
frmJys.TopLevel = false;
frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
frmJys.Show();
Form newForm;
foreach(Form from in this.MdiChildren)
{
if(from.Name == "")
{
newForm = from;
break;
}
}
if(null == newForm)
{
newForm = new Form();
}
public static bool IsOpen=false;=============
if(! frmJys.IsOpen)
{
frmJys frmJys = new frmJys();
frmJys.TopLevel = false;
frmJys.Parent = this.pnBack;//将窗体frmJys嵌入frmMain的panel控件中
frmJys.Show();
frmJys.IsOpen=true;
}
至于你想要的效果,住高楼上的朋友都解答的好