winforms - How to Use Dynamically Created Button/textBox in C# Windows Forms? -


private void createbutton() {     flowlayoutpanel1.controls.clear();      (int = 0; < 4; i++)     {             button b = new button();         b.name = i.tostring();         b.text = "button" + i.tostring();         flowlayoutpanel1.controls.add(b);     }  } private void button1_click(object sender, eventargs e) {     createbutton(); } 

i used code create buttons on runtime , how can use created buttons perform diffrent actions? im kindz new please me , appreciated :)

you can assign event handler click event:

b.click += somemethod; 

somemethod must have following signature:

void somemethod(object sender, eventargs e) 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -