码迷,mamicode.com
首页 > Windows程序 > 详细

Winform 随手记

时间:2017-11-21 14:53:34      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:reac   send   false   init   cli   rem   click   tar   one   

有关打开唯一窗口不是特别理解  手记

用Form1中的button 4 打开Form 5 这个唯一窗体

Form1中代码

 1         #region 打开唯一窗口
 2         public List<Form> FormList = new List<Form>();
 3 
 4         private void button4_Click(object sender, EventArgs e)
 5         {
 6             Form5 f5 = new Form5(this);
 7 
 8             bool has = false;
 9 
10             foreach (Form f in FormList)
11             {
12                 if (f is Form5)
13                 {
14                     has = true;
15                 }
16             }
17 
18             if (has == false)
19             {
20                 FormList.Add(f5);
21                 f5.Owner = this;
22                 f5.Show();
23             }
24             else
25             {
26 
27             }
28             #endregion

Form5中代码

 1         #region 打开唯一窗口
 2         Form1 F1 = null;
 3 
 4         public Form5(Form1 f1)
 5         {
 6             InitializeComponent();
 7             F1 = f1;
 8         }
 9 
10         private void Form5_Load(object sender, EventArgs e)
11         {
12             F1.FormList.Remove(this);
13         }
14         #endregion

 

Winform 随手记

标签:reac   send   false   init   cli   rem   click   tar   one   

原文地址:http://www.cnblogs.com/TheJoker/p/7872338.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!