⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 《c#技术内幕代码》
💻 CS
字号:
namespace ch9_13
{
    using System;
	using System.IO;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

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

        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.Windows.Forms.Button ();
			this.label1 = new System.Windows.Forms.Label ();
			this.richTextBox1 = new System.Windows.Forms.RichTextBox ();
			this.textBox1 = new System.Windows.Forms.TextBox ();
			//@this.TrayHeight = 0;
			//@this.TrayLargeIcon = false;
			//@this.TrayAutoArrange = true;
			button1.Location = new System.Drawing.Point (456, 544);
			button1.Size = new System.Drawing.Size (75, 23);
			button1.TabIndex = 3;
			button1.Text = "Show It!";
			button1.Click += new System.EventHandler (this.button1_Click);
			label1.Location = new System.Drawing.Point (16, 544);
			label1.Text = "Select File To display:";
			label1.Size = new System.Drawing.Size (120, 16);
			label1.TabIndex = 1;
			richTextBox1.Size = new System.Drawing.Size (736, 520);
			richTextBox1.TabIndex = 0;
			richTextBox1.Location = new System.Drawing.Point (8, 8);
			textBox1.Location = new System.Drawing.Point (152, 544);
			textBox1.Text = "textBox1";
			textBox1.TabIndex = 2;
			textBox1.Size = new System.Drawing.Size (288, 20);
			this.Text = "Form1";
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
			this.ClientSize = new System.Drawing.Size (760, 573);
			this.Controls.Add (this.button1);
			this.Controls.Add (this.textBox1);
			this.Controls.Add (this.label1);
			this.Controls.Add (this.richTextBox1);
		}

		protected void button1_Click (object sender, System.EventArgs e)
		{
            // Load the file
			string line = "";
			int    lineNo = 1;
			StreamReader sr = File.OpenText(this.textBox1.Text);
            while (sr.Peek()!=-1)
            {
                 String input = sr.ReadLine();
				 this.richTextBox1.Text += lineNo;
				 this.richTextBox1.Text += " ";
				 this.richTextBox1.Text += input;
				 this.richTextBox1.Text += "\r\n";
				lineNo ++;
		    }
            sr.Close();
  		}

        /// <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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -