Guest User

Untitled

a guest
Jun 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. private static int X = 100;
  2. private static int Y = 100;
  3. private void buttonDynamic_Click(object sender, EventArgs e)
  4. {
  5. AddButton(X, Y);
  6. X += 100;
  7. }
  8. private void AddButton(int x, int y)
  9. {
  10. // создаем контрол
  11. System.Windows.Forms.Button buttonDyn = new System.Windows.Forms.Button();
  12. // устанавливаем необходимые свойства
  13. buttonDyn.Location = new System.Drawing.Point(x, y);
  14. buttonDyn.Name = "button1";
  15. buttonDyn.Size = new System.Drawing.Size(75, 23);
  16. buttonDyn.TabIndex = 0;
  17. //вот здесь меняем цвет кнопки
  18. buttonDyn.BackColor = Color.Chartreuse;
  19. buttonDyn.UseVisualStyleBackColor = true;
  20. // button1_Click - функция обработчик события нажатия на кнопку
  21. buttonDyn.Click += new System.EventHandler(button1_Click);
  22. Controls.Add(buttonDyn); // добавляем на форму
  23.  
  24. }
  25.  
  26. Controls.Add(buttonDyn);
  27. buttonDyn.BackColor = Color.Chartreuse;
Add Comment
Please, Sign In to add comment