【发布时间】:2011-01-06 05:11:54
【问题描述】:
我有 MDI 应用程序并在焦点/选择上打开新表单。为了避免多次打开同一张图片,我写了这段代码,但它有一个问题
private void lstview1_MouseDoubleClick(object sender, MouseEventArgs e)
{
string window_name= this.lstview1.FocusedItem.Tag.ToString();
if (this.MdiChildren.Count() > 0)
{
if ( window_name == this.MdiChildren[i].Tag.ToString()) // At this point need ur help
{
this.MdiChildren[i].Activate();
}
else
{
Image_show_form(image, window_name);
}
}
else
{
Image_show_form(image, window_name);
}
}
childform 标记又是 int.parse(window_name)。 但它会引发错误,这使得 sensce [ this.MdiChildren[index].Tag] 需要首先存在。 我怎样才能检查这个存在/或者我怎样才能让我的代码更好。
【问题讨论】:
标签: c#