Horje
add dynamically buttons in loop with events winform c# Code Example
add dynamically buttons in loop with events winform c#
for (int i = 0; i < 5; i++)
     {
        Button button = new Button();
        button.Location = new Point(160, 30 * i + 10);
        button.Click += new EventHandler(ButtonClickOneEvent);
        button.Tag = i;
        this.Controls.Add(button);
     }

void ButtonClickOneEvent(object sender, EventArgs e)
  {
     Button button = sender as Button;
     if (button != null)
     {
        // now you know the button that was clicked
        switch ((int)button.Tag)
        {
           case 0:
              // First Button Clicked
              break;
           case 1:
              // Second Button Clicked
              break;
           // ...
        }
     }
  }




Csharp

Related
unity string array Code Example unity string array Code Example
c# negative index Code Example c# negative index Code Example
game object find Code Example game object find Code Example
how to open any file on button click in winforms Code Example how to open any file on button click in winforms Code Example
audiomixer get float Code Example audiomixer get float Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11