winforms - Common event for the list of button in window forms? -


in window forms, can implement common click event button in "flowlayoutpanel", can me. thank in advance.

yes, can have common handler event. creating button controls:

for (int32 = 0; < 3; i++) {     button b = new button();     b.name = "button" + i;     // or:  b.tag = i;     b.click += button_click;     flowlayoutpanel1.controls.add(b);  //or whatever add them to... } 

now have specified same handler each button:

private void button_click(object sender, eventargs e) {     button b = (button)sender;     switch (b.name)  // or: switch (b.tag) , react integers instead of strings     {         case "button0":             break;         case "button1":             break;         case "button2":             break;     } } 

in short, need way identify each button , react identifier when common handler called.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -