【发布时间】:2013-09-29 21:30:51
【问题描述】:
好的,如果新表单尚未打开,我想打开它。所以我根据表单的标题或文本检查表单。现在,到目前为止它可以工作,因为表单打开了,如果它已经打开,它只是将它带到前面。但我的问题是,如果它没有打开,并且我尝试创建它的新实例,它会抛出“集合已修改;枚举操作可能无法执行”。而且我终其一生都无法弄清楚为什么。任何帮助表示赞赏。
foreach (DataRow iRow in chatcheck.Rows)
{
FormCollection fc = Application.OpenForms;
foreach (Form f in fc)
{
if (f.Text != ChatReader["Sender"].ToString())
{
ChatBox chat = new ChatBox();
Connection.ConnectionStrings.chatopen = ChatReader["Sender"].ToString();
chat.Text = Connection.ConnectionStrings.chatopen;
chat.Show();
chat.BringToFront();
}
else if (f.Text == ChatReader["Sender"].ToString())
{
f.BringToFront();
}
}
}
【问题讨论】:
标签: c# foreach datatable sqldataadapter openform