jonathanh8686
jonathanh8686

Reputation: 78

How do I find out what button was clicked?

If I have 150 buttons Is it possible to not have to have a individual button_Click Methods.

    public Button findClicked(object sender, EventArgs e)
    {
        Button btnClicked = (Some code)
        return btnClicked;
    }

Upvotes: 0

Views: 87

Answers (2)

Max
Max

Reputation: 156

try this:

Button button = sender as Button;
var name = button.Name;

Upvotes: 0

bit
bit

Reputation: 4487

Button btnClicked = (Button)sender; 

Upvotes: 4

Related Questions