VS2012窗口操作简单演示

时间:2022-09-02 20:33:42

呵呵,终于进入到我感兴趣的窗口方面的操作啦。。

三个窗口的SHOW和HIDE。。。

PROGRAM.CS中记录第一个加载的窗口FORM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

FORM1.CS的主要代码如下:

 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 WindowsFormsApplication1
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19 
20         private void label1_Click(object sender, EventArgs e)
21         {
22 
23         }
24 
25         private void button1_Click(object sender, EventArgs e)
26         {
27             Form2 frm2 = new Form2();
28             frm2.Show();
29         }
30 
31         private void button2_Click(object sender, EventArgs e)
32         {
33             Form3 frm3 = new Form3();
34             frm3.Show();
35         }
36 
37         private void Form1_Load(object sender, EventArgs e)
38         {
39         }
40     }
41 }

至于下面这个代友乾坤,以后要慢慢研究的。

好像不建议手工更改,都是通过界面设置属性的。

 1 namespace WindowsFormsApplication1
 2 {
 3     partial class Form1
 4     {
 5         /// <summary>
 6         /// Required designer variable.
 7         /// </summary>
 8         private System.ComponentModel.IContainer components = null;
 9 
10         /// <summary>
11         /// Clean up any resources being used.
12         /// </summary>
13         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14         protected override void Dispose(bool disposing)
15         {
16             if (disposing && (components != null))
17             {
18                 components.Dispose();
19             }
20             base.Dispose(disposing);
21         }
22 
23         #region Windows Form Designer generated code
24 
25         /// <summary>
26         /// Required method for Designer support - do not modify
27         /// the contents of this method with the code editor.
28         /// </summary>
29         private void InitializeComponent()
30         {
31             this.button1 = new System.Windows.Forms.Button();
32             this.button2 = new System.Windows.Forms.Button();
33             this.label1 = new System.Windows.Forms.Label();
34             this.SuspendLayout();
35             // 
36             // button1
37             // 
38             this.button1.Location = new System.Drawing.Point(118, 260);
39             this.button1.Name = "button1";
40             this.button1.Size = new System.Drawing.Size(75, 23);
41             this.button1.TabIndex = 0;
42             this.button1.Text = "第一本";
43             this.button1.UseVisualStyleBackColor = true;
44             this.button1.Click += new System.EventHandler(this.button1_Click);
45             // 
46             // button2
47             // 
48             this.button2.Location = new System.Drawing.Point(258, 260);
49             this.button2.Name = "button2";
50             this.button2.Size = new System.Drawing.Size(75, 23);
51             this.button2.TabIndex = 1;
52             this.button2.Text = "第二本";
53             this.button2.UseVisualStyleBackColor = true;
54             this.button2.Click += new System.EventHandler(this.button2_Click);
55             // 
56             // label1
57             // 
58             this.label1.AutoSize = true;
59             this.label1.Font = new System.Drawing.Font("Adobe Arabic", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
60             this.label1.Location = new System.Drawing.Point(92, 205);
61             this.label1.Name = "label1";
62             this.label1.Size = new System.Drawing.Size(303, 33);
63             this.label1.TabIndex = 2;
64             this.label1.Text = "最近看的计算机图书";
65             this.label1.Click += new System.EventHandler(this.label1_Click);
66             // 
67             // Form1
68             // 
69             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
70             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
71             this.BackColor = System.Drawing.SystemColors.HotTrack;
72             this.ClientSize = new System.Drawing.Size(449, 505);
73             this.Controls.Add(this.label1);
74             this.Controls.Add(this.button2);
75             this.Controls.Add(this.button1);
76             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
77             this.Name = "Form1";
78             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
79             this.Text = "窗体操作简单演示";
80             this.Load += new System.EventHandler(this.Form1_Load);
81             this.ResumeLayout(false);
82             this.PerformLayout();
83 
84         }
85 
86         #endregion
87 
88         private System.Windows.Forms.Button button1;
89         private System.Windows.Forms.Button button2;
90         private System.Windows.Forms.Label label1;
91     }
92 }

效果图:

VS2012窗口操作简单演示