日期:2014-05-19  浏览次数:20687 次

一个Winform如何只能产生一个实例?
RT:请高手指点,一个维护部门资料的WinForm,当我点击相应菜单项时判断是否已经打开这个WinForm,如果已打开则不许再开一实例.

------解决方案--------------------
打开前判断一下

WinForm newWinForm = null;

private void button1_Click(object sender, EventArgs e)
{
if (newWinForm == null || newWinForm.IsDisposed)
{
newWinForm= new WinForm(this);
newWinForm.Show();
}
else
{
newWinForm.Active();
}
}