📄 form1.cs
字号:
namespace ch9_14
{
using System;
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 button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.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.Windows.Forms.Button ();
this.label1 = new System.Windows.Forms.Label ();
this.button2 = new System.Windows.Forms.Button ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
button1.Location = new System.Drawing.Point (104, 32);
button1.Size = new System.Drawing.Size (88, 24);
button1.TabIndex = 1;
button1.Text = "Icon";
button1.Click += new System.EventHandler (this.button1_Click);
label1.Location = new System.Drawing.Point (16, 40);
label1.Text = "Select an icon:";
label1.Size = new System.Drawing.Size (80, 24);
label1.TabIndex = 0;
button2.Location = new System.Drawing.Point (168, 96);
button2.ForeColor = System.Drawing.Color.White;
button2.BackColor = System.Drawing.Color.Blue;
button2.Size = new System.Drawing.Size (75, 23);
button2.TabIndex = 2;
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 (264, 149);
this.Controls.Add (this.button2);
this.Controls.Add (this.button1);
this.Controls.Add (this.label1);
}
protected void button1_Click (object sender, System.EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
if ( fd.ShowDialog() == DialogResult.OK )
{
// Load the icon file
System.Drawing.Icon icon = new System.Drawing.Icon(fd.FileName);
// Now set the form to be that icon
this.Icon = icon;
}
}
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 + -