winform - 窗体

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 
11 namespace WinApp01_Eason
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19         //
20         // 窗口最大化
21         private void btnMaxWindow_Click(object sender, EventArgs e)
22         {
23             this.WindowState = FormWindowState.Maximized;
24         }
25         //
26         // 窗口恢复
27         private void btnNormalWindow_Click(object sender, EventArgs e)
28         {
29             this.WindowState = FormWindowState.Normal;
30         }
31         //
32         // 窗口最小化
33         private void btnMinWindow_Click(object sender, EventArgs e)
34         {
35             this.WindowState = FormWindowState.Minimized;
36         }
37         //
38         // 创建frmHello窗口
39         private void btnShowHello_Click(object sender, EventArgs e)
40         {
41             frmHello fmhello = new frmHello();
42             fmhello.Show();
43         }
44         //
45         // 退出程序
46         private void btnAppExit_Click(object sender, EventArgs e)
47         {
48             Application.Exit();
49         }
50         //
51         // 显示隐藏的窗体
52         private void btnCloseHideWindow_Click(object sender, EventArgs e)
53         {
54             /***********************************************************************
55              *  方法1 :
56              // 遍历打开的窗体并转换成数组赋值给forms
57             Form[] forms = Application.OpenForms.Cast<Form>().ToArray();
58             foreach (Form frm in forms)
59             {
60                 // 如果当前窗口可视为假,说明当前窗口是隐藏的
61                 if (false == frm.Visible)
62                 {
63                     // 那么就显示窗口
64                     frm.Visible = true;
65                 }
66             }
67             
68             ***********************************************************************/
69 
70             //方法2
71             foreach ( Form hideform in Application.OpenForms)
72             {
73                 if (null != hideform && false == hideform.Visible)
74                 {
75                     hideform.Visible = true;
76                 }
77             }
78             
79         }
80     }
81 }

posted @ 2016-04-02 21:35  C/C++/Python/Java  阅读(467)  评论(0编辑  收藏  举报