子窗体不重复
private static Form1 f1;
private Form1 getf1()
{
if (f1 == null || f1.IsDisposed)
{
f1 = new Form1();
f1.MdiParent=this;
}
return f1;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
Form1 f1 = getf1();
f1.Show();
f1.Focus();
}
------解决方案--------------------用进程锁
bool create;
Mutex m=new Mutex(true, "text ",out create);
if(create)
{
Application.Run(new Form1());
m.ReleaseMutex();
}
这段代码加到子窗体的构造函数中