c# event在form中手工编写一个按钮button

//InitializeComponent为设计生成的方法代码


  1. private System.Windows.Forms.Button btn_ok;
  2. private void InitializeComponent()
        {

// 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();

           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的代码
 private void btn_ok_click(object sender, EventArgs e)
        {
            label1.Text = "手工编写事件处理代码,为了订阅事件所用";
        }


请使用浏览器的分享功能分享到微信等