public partial class MainMenu : Form
{
public MainMenu()
{
InitializeComponent();
}
windowOne One;
windowTwo Two;
private void OneToolStripMenuItem_Click(object sender, EventArgs e)
{
if (One != null)
{
One.WindowState = FormWindowState.Normal;
One.Focus();
}
else
{
One = new windowOne();
One.MdiParent = this;
One.FormClosed += (o, ea) => One = null;
One.Show();
}
}
private void TwoToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Two != null)
{
TwoWindowState = Two.Normal;
Two.Focus();
}
else
{
Two = new windowTwo();
Two.MdiParent = this;
Two.FormClosed += (o, ea) => Two = null;
Two.Show();
}
}
我是 C# 的初学者,我正在开发窗口应用程序,我希望当 windowOne 打开时用户无法打开 windowTwo,我使用上面的代码来避免再次打开 windowOne 或 windowTwo ..