winform只显示一个窗体
private void button1_Click(object sender, EventArgs e)
{
//点击按钮的时候只会显示一个窗体
bool opened = false;
foreach (Form f1 in Application.OpenForms)
{
if (f1 is Form2)
{
opened = true;
break;
}
}
if (!opened)
{
Form2 f2 = new Form2();
f2.Show();
}
}