I need some help on how can i put some Event handler on my Button mybtn using code.

 private void button1_Click(object sender, EventArgs e)
 {
      Button mybtn = new Button();  
      mybtn.Text = "First"; 

        FlowLayoutPanel flowlayoutpl = new FlowLayoutPanel();
        flp.Controls.Add(mybtn);
        panel.Controls.Add(flowlayoutpl);
 }

Recommended Answers

You would add something like either of the following statements:

mybtn.Click += new EventHandler(mybtn_Click);
//--or--
mybtn.Click += mybtn_Click;
Jump to Post

All 2 Replies

You would add something like either of the following statements:

mybtn.Click += new EventHandler(mybtn_Click);
//--or--
mybtn.Click += mybtn_Click;

wow thanks,it's working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.