//InitializeComponent为设计生成的方法代码
- private System.Windows.Forms.Button btn_ok;
- private void InitializeComponent()
{
btn_ok.Location = new System.Drawing.Point(10, 80);
btn_ok.Name = "btn_ok";
btn_ok.Text = "手工按钮";
btn_ok.Size = new System.Drawing.Size(75, 23);
//eventhandler方法的参数就是事件名称,其实就是方法,
//你要手工编写,不然提示上下文找不到错误
btn_ok.Click += new System.EventHandler(this.btn_ok_click);
}
3,form1.cs关于事件btn_ok_click的代码
// Form1
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.btn_ok);
this.Name = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.btn_ok);
this.Name = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
btn_ok.Location = new System.Drawing.Point(10, 80);
btn_ok.Name = "btn_ok";
btn_ok.Text = "手工按钮";
btn_ok.Size = new System.Drawing.Size(75, 23);
//eventhandler方法的参数就是事件名称,其实就是方法,
//你要手工编写,不然提示上下文找不到错误
btn_ok.Click += new System.EventHandler(this.btn_ok_click);
}
private void btn_ok_click(object sender, EventArgs e)
{
label1.Text = "手工编写事件处理代码,为了订阅事件所用";
}
{
label1.Text = "手工编写事件处理代码,为了订阅事件所用";
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-718079/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-718079/