现有两个按钮A,B 点击A时 执行如下代码, NewMail newMail = new NewMail(mailMode);
newMail.Show();每次弹出form NewMail , 当点击多次A后, 想通过点B把所有打开的NewMail对话框全关掉, 该如何实现啊 ????谢谢各位了!
newMail.Show();每次弹出form NewMail , 当点击多次A后, 想通过点B把所有打开的NewMail对话框全关掉, 该如何实现啊 ????谢谢各位了!
在show的时候,把新增的窗体添加到listForms
listForms.Add(newForm);
关闭所有窗体
foreach(From frm in listForms)
{
frm.Close();
}
private void button1_Click(object sender, EventArgs e)
{
NewMail newMail = new NewMail();
newMail.Show();
} private void button2_Click(object sender, EventArgs e)
{
while (Application.OpenForms.Count > count)
{
Application.OpenForms[count].Close();
}
} private void Form1_Load(object sender, EventArgs e)
{
count = Application.OpenForms.Count;
}