欧美特黄不卡,涩涩视频在线,成人国产精品一区二区网站,亚洲一区二区三区欧美

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

MDI應用中的單案例(singleton)窗口

MDI應用中的單案例(singleton)窗口

更新時間:2022-04-29 文章作者:未知 信息來源:網絡 閱讀次數:

下面的代碼片斷假設你的多文檔應用程序中包含一個toolbar。當你點擊toolBarButton1 按鈕時,將會創建并顯示一個 Patients 子窗口。下面的代碼在單機事件時發生。

private void toolBar1_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
// a flag to store if the child form is opened or not
bool found = false;

if (e.Button == toolBarButton1)
{
// get all of the MDI children in an array
Form[] charr = this.MdiChildren;

if (charr.Length == 0) // no child form is opened
{
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();
}
else // child forms are opened
{

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();
}
}
}
}
這樣,就實現了一個單窗口實例的解決方案。

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 罗城| 芦溪县| 清原| 景宁| 伊吾县| 永清县| 安仁县| 浪卡子县| 靖西县| 阳高县| 东安县| 尤溪县| 霸州市| 井冈山市| 大名县| 阳谷县| 太保市| 苍溪县| 湟中县| 平原县| 东宁县| 郴州市| 榕江县| 顺昌县| 承德县| 禄丰县| 台北县| 社旗县| 呼图壁县| 兴文县| 米泉市| 卢氏县| 沙坪坝区| 吉木萨尔县| 开原市| 沧州市| 资溪县| 鄱阳县| 安西县| 涪陵区| 广西|