Непоказываются кнопки на форме при вызове класса - C#
Формулировка задачи:
Не показываются кнопки на форме, почему ? Где я допустила ошибку ?
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Drawing;
namespace tic_tac_toe_express_game
{
public class Game_Buttons
{
private Button[] button = new Button[9];
private string[] button_name = new string[9];
public void CreateButton()
{
for (int i = 0; i < button_name.Length; i++)
{
button_name[i] = null;
}
for (int i = 0; i < button.Length; i++)
{
this.button[i] = new Button();
this.button[i].Location = new Point(12 + 5, 12 + 5);
this.button[i].Name = "game_button_" + i;
this.button[i].Size = new Size(75, 55);
this.button[i].TabIndex = i;
this.button[i].Text = null;
this.button[i].UseVisualStyleBackColor = true;
}
}
}
}using System;
using System.Drawing;
using System.Windows.Forms;
namespace tic_tac_toe_express_game
{
public partial class main_form_1 : Form
{
Game_Buttons buttons = new Game_Buttons();
public main_form_1()
{
InitializeComponent();
buttons.CreateButton();
}
}
}Решение задачи: «Непоказываются кнопки на форме при вызове класса»
textual
Листинг программы
using System;
using System.Drawing;
using System.Windows.Forms;
namespace tic_tac_toe_express_game
{
public partial class main_form_1 : Form
{
Game_Buttons buttons = new Game_Buttons();
public main_form_1()
{
InitializeComponent();
buttons.CreateButton();
foreach (var dummy_button in buttons.button_list)
this.Controls.Add(dummy_button);
}
}
}