📄 12-6.cs
字号:
//程序12-6
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
public class TheForm : Form
{
private TextBox textbox;
private Button button;
private Label label;
public TheForm() : base()
{
textbox = new TextBox();
textbox.Size = new Size(100,100);
textbox.Location = new Point(150,50);
textbox.Text = " ";
button = new Button();
button.Location = new Point(50,100);
button.Text = "演示";
label=new Label();
label.Location=new Point(50,50);
label.Size=new Size(150,100);
label.Text="演示事件";
button.Click += new EventHandler(this.Button_Clicked); //创建委托并添加到事件
Controls.Add(textbox);
Controls.Add(button);
Controls.Add(label);
}
private void Button_Clicked(object sender, EventArgs e) //事件处理程序.
{
textbox.Text = "事件响应了!";
}
public static void Main(string[] args)
{
Application.Run(new TheForm());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -