form1.cs

来自「《c#技术内幕代码》」· CS 代码 · 共 105 行

CS
105
字号
namespace CH8_17
{
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.WinForms;
    using System.Data;

    /// <summary>
    ///    Summary description for Form1.
    /// </summary>
    public class Form1 : System.WinForms.Form
    {
        /// <summary>
        ///    Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components;
		private System.WinForms.Button button2;
		private System.WinForms.Button button1;
		private System.WinForms.TextBox textBox1;
		private System.WinForms.Label label1;

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        ///    Clean up any resources being used.
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();
            components.Dispose();
        }

        /// <summary>
        ///    Required method for Designer support - do not modify
        ///    the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container ();
			this.button1 = new System.WinForms.Button ();
			this.label1 = new System.WinForms.Label ();
			this.textBox1 = new System.WinForms.TextBox ();
			this.button2 = new System.WinForms.Button ();
			//@this.TrayHeight = 0;
			//@this.TrayLargeIcon = false;
			//@this.TrayAutoArrange = true;
			button1.Location = new System.Drawing.Point (152, 64);
			button1.Size = new System.Drawing.Size (75, 23);
			button1.TabIndex = 2;
			button1.Text = "&Copy";
			button1.Click += new System.EventHandler (this.button1_Click);
			label1.Location = new System.Drawing.Point (16, 16);
			label1.Text = "Enter text to copy to clipboard:";
			label1.Size = new System.Drawing.Size (152, 23);
			label1.TabIndex = 0;
			textBox1.Location = new System.Drawing.Point (176, 16);
			textBox1.TabIndex = 1;
			textBox1.Size = new System.Drawing.Size (272, 20);
			button2.Location = new System.Drawing.Point (304, 64);
			button2.Size = new System.Drawing.Size (75, 23);
			button2.TabIndex = 3;
			button2.Text = "E&xit";
			button2.Click += new System.EventHandler (this.button2_Click);
			this.Text = "Form1";
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
			this.ClientSize = new System.Drawing.Size (560, 109);
			this.Controls.Add (this.button2);
			this.Controls.Add (this.button1);
			this.Controls.Add (this.textBox1);
			this.Controls.Add (this.label1);
		}

		protected void button2_Click (object sender, System.EventArgs e)
		{
            Close();
		}

		protected void button1_Click (object sender, System.EventArgs e)
		{
             if ( textBox1.Text != "")
                Clipboard.SetDataObject(textBox1.Text);
   		}

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string[] args) 
        {
            Application.Run(new Form1());
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?