📄 form1.cs
字号:
namespace CH9_3
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
/// <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 button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
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.textBox1 = new System.Windows.Forms.TextBox ();
this.button1 = new System.Windows.Forms.Button ();
this.label1 = new System.Windows.Forms.Label ();
this.listBox1 = new System.Windows.Forms.ListBox ();
this.button2 = new System.Windows.Forms.Button ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
textBox1.Location = new System.Drawing.Point (96, 24);
textBox1.TabIndex = 2;
textBox1.Size = new System.Drawing.Size (100, 20);
button1.Location = new System.Drawing.Point (200, 24);
button1.Size = new System.Drawing.Size (40, 23);
button1.TabIndex = 3;
button1.Text = "&List";
button1.Click += new System.EventHandler (this.button1_Click);
label1.Location = new System.Drawing.Point (8, 24);
label1.Text = "Enter Directory:";
label1.Size = new System.Drawing.Size (80, 16);
label1.TabIndex = 1;
listBox1.Location = new System.Drawing.Point (48, 64);
listBox1.Size = new System.Drawing.Size (152, 160);
listBox1.TabIndex = 0;
button2.Location = new System.Drawing.Point (88, 232);
button2.Size = new System.Drawing.Size (75, 23);
button2.TabIndex = 4;
button2.Text = "&Close";
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 (292, 261);
this.Controls.Add (this.button2);
this.Controls.Add (this.button1);
this.Controls.Add (this.textBox1);
this.Controls.Add (this.label1);
this.Controls.Add (this.listBox1);
}
protected void button1_Click (object sender, System.EventArgs e)
{
if ( this.textBox1.Text.Length != 0 )
{
// Load the list box
string[] files = Directory.GetFiles( this.textBox1.Text );
foreach( string s in files )
{
this.listBox1.Items.Add( s );
}
}
}
protected void button2_Click (object sender, System.EventArgs e)
{
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 + -