打开一个子窗口,同时关闭已打开子窗口的代码如下
private consumer f_consumer;
private void ConsumerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.MdiChildren.Length > 0)
this.MdiChildren[0].Close();
if (f_consumer == null || f_consumer.IsDisposed)
{
f_consumer = new consumer();
f_consumer.MdiParent = this;
f_consumer.Location = new Point(0, 0);
f_consumer.Width = f_consumer.Parent.ClientSize.Width;
f_consumer.Height = f_consumer.Parent.ClientSize.Height;
f_consumer.Show();
f_consumer.Activate();
}
else
{
f_consumer.Focus();
}
}