用C#如何防止MDI子窗体被多次实例化

if(this._IsExistChildForm("ChildForm"))
{
return;
}
ChildForm childForm= new ChildForm();
childForm.MdiParent = this;
childForm.Name = "ChildForm";
childForm.Show();

/// <summary>
/// 判断是否含有该子窗体
/// </summary>
/// <param name="_ChildFormName">子窗体名称</param>
/// <returns>bool</returns>
private bool _IsExistChildForm(string _ChildFormName)
{
foreach(Form form in this.MdiChildren)
{
if(string.Compare(form.Name, _ChildFormName, true) == 0)
{
form.BringToFront();
return true;
}
}
return false;
}
posted @ 2005-09-03 00:29  泡面 @ 幸福  阅读(690)  评论(0编辑  收藏  举报