I'm working on a project where I have in a form 5 to 10 buttons, everything manually added (from code) and I need to see which button was clicked on.

Button Remove = new Button();
Remove.Name = i.ToString();
Remove.Text = "Remove";
Remove.Click += new EventHandler(Remove_Clicked());

 void Remove_Clicked(object sender, EventArgs e)

I named the buttons in numbers (i) so i can get them easier.

So is there a way to check which button was pressed?


Could u please give me code or something? because I'm not that good at events since they didnt teach us at school about them and all I know is the few things that I read on the internet

Here's an example for first web apps, then Windows apps.

string str = new string(((Button)sender).ID);
string str = new string(((Button)sender).Name);

Hope that helps.

That fixed my problem, thanks
This question has already been answered. Start a new discussion instead.