Hi hows it going
ive made dynamic buttons and added a button click event
ButtonClick(object sender,eventargs e)
Im sending all the Buttons created 1 to 3
I dont know how to get which button was clicked
The "sender" parameter is a reference to the control instance that
generated the click. If you want the Button itself, you can just cast
that to the Button type, or if all you need is something from the base
Control class (e.g. the Tag property, commonly used to associate data with
a particular control), just cast it to the Control type.
You can even just compare the reference to your class variables that
reference each button (e.g. "button1", "button2", etc.). IMHO this is the
least preferable way to handle special-case behavior for a given button in
a shared handler, but for small numbers of buttons it's not actually all
that bad.
Finally, it probably goes without saying, but if you have drastically
different behavior in the handler depending on which button is clicked,
it's better to just have a different handler for each button.
Pete