正在阅读:MDI应用中的单实例(singleton)窗口MDI应用中的单实例(singleton)窗口

2004-06-25 09:53 出处:CSDN 作者:turnmissile [翻译] 责任编辑:linjixiong


         foreach (Form chform in charr)
          {
            if (chform.Name == "Patients")
            // one instance of the form is already opened
            {
              chform.Activate();
              found = true;
              break;   // exit loop
            }
            else
              found = false;      // make sure flag is set to
                                  // false if the form is not found
          }
 
          if (found == false)   
          {
            Patients myPatients = new Patients();
            myPatients.MdiParent = this;
            // The StartPosition property is essential
            // for the location property to work
            myPatients.StartPosition = FormStartPosition.Manual;
            myPatients.Location = new Point(0,0);
            myPatients.Show();
          }
        }
    }
}

   这样,就实现了一个单窗口实例的解决方案。


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品