日本国产亚洲-日本国产一区-日本国产一区二区三区-日本韩国欧美一区-日本韩国欧美在线-日本韩国欧美在线观看

當(dāng)前位置:雨林木風(fēng)下載站 > 技術(shù)開發(fā)教程 > 詳細(xì)頁面

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

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

更新時間:2022-04-29 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

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

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

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

本類教程下載

系統(tǒng)下載排行

主站蜘蛛池模板: 亚洲欧美综合视频 | 欧美一级精品高清在线观看 | 国产精品视频一区二区三区w | 国产在线观看入口 | 亚洲欧美一区二区三区不卡 | 精品久久看 | 国产综合影院 | 久久久久亚洲精品一区二区三区 | 色在线免费视频 | 亚洲精品欧美精品国产精品 | 日韩欧美在线综合网高清 | 正在播放黑丝 | 第一福利视频 | 欧美视频一区二区三区四区 | 欧美熟色妇 | 天天插天天干天天操 | 草久免费视频 | 欧美日韩亚洲在线 | 国产hs免费高清在线观看 | 国产成人v片视频在线观看 国产成人v视频在线观看 | 操一操干一干 | 5g影院天天爽爽 | 精品成人网 | 天天五g天天爽 | 免费久草| 日韩精品无码一区二区三区 | 亚洲国产视频一区 | 黄网站在线免费 | 亚洲激情久久 | 曰批免费视频播放在线看片二 | 国产二区三区毛片 | 天天干天天拍 | 午夜影院男女 | 99久久99热久久精品免 | 四虎欧美 | 夜夜操天天射 | 深夜久久| 日本免费观看高清视频大全 | 国产成人精品免费视频大全可播放的 | 久草久草久草久草 | jizzzz日本|