-1

I'm working on a c# winforms application.I have created buttons from the back end, like the following:

Button b = new Button();

How can I attach a click to each button that is created from the back end, that each button when clicked, a picture should become visible.

sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
Jane Cohen
  • 89
  • 1
  • 12
  • 2
    Possible duplicate of [How can I create a dynamic button click event on a dynamic button?](https://stackoverflow.com/questions/6187944/how-can-i-create-a-dynamic-button-click-event-on-a-dynamic-button) – Abbas Apr 17 '18 at 12:14

1 Answers1

2

You can register events like this:

Button b = new Button();
b.Click += customButton_Click;
public void customButton_Click(object sender, EventArgs e)
{
   // code here
}

Here the += operator will helps you to register the event handlers.

sujith karivelil
  • 28,671
  • 6
  • 55
  • 88