📄 winevents.cs
字号:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
public class MyForm : Form
{
private TextBox box;
private Button button;
public MyForm() : base()
{
box = new TextBox();
box.BackColor = System.Drawing.Color.Cyan;
box.Size = new Size(100,100);
box.Location = new Point(50,50);
box.Text = "Hello";
button = new Button();
button.Location = new Point(50,100);
button.Text = "Click Me";
// To wire the event, create
// a delegate instance and add it to the Click event.
button.Click += new EventHandler(this.Button_Clicked);
Controls.Add(box);
Controls.Add(button);
}
// The event handler.
private void Button_Clicked(object sender, EventArgs e)
{
box.BackColor = System.Drawing.Color.Green;
}
// STAThreadAttribute indicates that Windows Forms uses the
// single-threaded apartment model.
[STAThreadAttribute]
public static void Main(string[] args)
{
Application.Run(new MyForm());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -