部分代码:
//关闭其他窗口
FormCollection childCollection = Application.OpenForms;
for (int i = childCollection.Count; i-- > 0;)
{
if (childCollection[i] != this)
childCollection[i].Close();
else
break;
}
按键实现:
private void t10chapwd_Click(object sender, EventArgs e)
{
//关闭其他窗口
FormCollection childCollection = Application.OpenForms;
for (int i = childCollection.Count; i-- > 0;)
{
if (childCollection[i] != this)
childCollection[i].Close();
else
break;
}
this.IsMdiContainer = true;
change_the_password chapwd = new change_the_password();
chapwd.MdiParent = this;//this新窗口的父窗口
chapwd.userno3 = userno1;//传参
chapwd.Show();
}