📄 8.3.txt
字号:
Listing 8.3 Associating Events with an Event Handler Using the Multicast Delegate
Syntax
private void InitializeComponent()
{
this.sayHello = new System.Windows.Forms.Button();
this.closeForm = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sayHello
//
this.sayHello.Location = new System.Drawing.Point(98, 16);
this.sayHello.Name = “sayHello”;
this.sayHello.Size = new System.Drawing.Size(96, 23);
this.sayHello.TabIndex = 0;
this.sayHello.Text = “Say Hello”;
// event handler association for the Click event
this.sayHello.Click += new System.EventHandler(this.sayHello_Click);
//
// closeForm
//
this.closeForm.Location = new System.Drawing.Point(98, 64);
this.closeForm.Name = “closeForm”;
this.closeForm.Size = new System.Drawing.Size(96, 23);
this.closeForm.TabIndex = 1;
this.closeForm.Text = “Close Form”;
this.closeForm.Click += new System.EventHandler(this.closeForm_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 118);
this.Controls.Add(this.closeForm);
this.Controls.Add(this.sayHello);
this.Name = “Form1”;
this.Text = “Form1”;
this.ResumeLayout(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -