int num = Application.OpenForms.Count;
for (int i = 0; i < num; i++)
{
Form f = Application.OpenForms[i];
if (f.Name != 窗体名字)
{
f.Close();
num = num - 1;
i = i - 1;
}
}
#4
用foreach 来的容易些。
#5
foreach 会报错,关闭一个 foreach里面就少了一个再循环就错了
#1
没有人做过这方面的功能吗?
大神们都进来吧
#2
遍历当前Application 中的所有forms,根据窗体的Name 进行关闭。
#3
int num = Application.OpenForms.Count;
for (int i = 0; i < num; i++)
{
Form f = Application.OpenForms[i];
if (f.Name != 窗体名字)
{
f.Close();
num = num - 1;
i = i - 1;
}
}
#4
int num = Application.OpenForms.Count;
for (int i = 0; i < num; i++)
{
Form f = Application.OpenForms[i];
if (f.Name != 窗体名字)
{
f.Close();
num = num - 1;
i = i - 1;
}
}
用foreach 来的容易些。
#5
int num = Application.OpenForms.Count;
for (int i = 0; i < num; i++)
{
Form f = Application.OpenForms[i];
if (f.Name != 窗体名字)
{
f.Close();
num = num - 1;
i = i - 1;
}
}