Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- List<Button> buttons = new List<Button>();
- Button btn;
- int x = 0;
- private void yourMethod(object sender, EventArgs e)
- {
- this.Text = "Hello";
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //создание кнопки
- x += 70;
- btn = new Button();
- btn.Text = "b" + x;
- btn.Left = x;
- btn.Top = 100;
- btn.Height = 50;
- btn.Width = 50;
- this.Controls.Add(btn);
- //добавляем событие
- btn.Click += new EventHandler(yourMethod);
- //добавляем в коллекцию
- buttons.Add(btn);
- //выводим количество
- label1.Text = buttons.Count.ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement