非顶级窗体不能显示为模式对话框。在调用 showDialog 之前应从所有父窗体中移除该窗体。
解决方案 »
- 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作
- 为什么我用子类调用子类的一个重写了的方法,它却调用父类的虚方法
- c#如何使用配置文件,winform编程
- 大家看看我这种情况用什么控件比较容易
- 向Form添加组件(不是控件),该组件会出现在下方的组件设计器中。比如添加Timer.如果不想让该组件出现在下方的组件设计器中,如何做
- winform怎样罗列电脑上连接的所有摄像头?
- C#题,请赐教
- 【求解】C# 解压文件到内存,然后分析内存中的文件把数据保存到数据库
- .net使用联通SGIP协议开发发送短信的程序
- 消息传递
- 如何在.net中使用用C写的类库
- win2000下C#制作的应用程序窗体变形
比如子窗体名为childForm
if(childForm == null)
{
childForm = new ChildForm();
}
childForm.show();
或者直接用ShowDialog()
用ShowDialog()简单点
对象名:“InsertData”。7楼的大哥,别忽悠我行不?第一次那样是不多弹了,可我关了再按文件,就异常````
代码写死了啊
if (mCh.Created)
{
mCh.BringToFront();
}
else
{
mCh = new frmChild();
mCh.MdiParent = 父窗体;
mCh.Show();
}
frmChild mCh =new frmChild();
if (mCh.Created)
{
mCh.BringToFront();
}
else
{
mCh = new frmChild();
mCh.MdiParent = 父窗体;
mCh.Show();
}
{
.........
frmChild mCh =new frmChild(); //是这里先定义一下。
}以下代码是在frmMain里打开子窗体时使用。
if (mCh.Created)
{
mCh.BringToFront();
}
else
{
mCh = new frmChild();
mCh.MdiParent = this;
mCh.Show();
}
private void ShowSubForm(Form ParentForm, string SubFormName)
{
Form childForm;
bool flag = false; if (ParentForm.MdiChildren.Length != 0)
{
int childCount = ParentForm.MdiChildren.Length;
for (int i = 0; i < childCount; i++)
{
childForm = ParentForm.MdiChildren[i];
if (childForm.Name == SubFormName)
{
flag = true;
childForm.Activate();
break;
}
}
}
if (!flag)
{
childForm = (Form)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance("在这里写命名空间名称" + SubFormName);
if (childForm == null)
{
MessageBox.Show("没有找到窗口!");
return;
}
childForm.MdiParent = ParentForm;
childForm.Show();
}
}
然后调用该方法就可以了。