C# フォームにいくつかのボタンをプログラムで追加しましたが、デザイナーを介して追加したボタンのみが実際に表示されます。残りは見えないままです。この前に多くの操作を実行しています。これが原因なのではないでしょうか?
public FormView
{
List<Button> listOfButtons = new List<Button>();
int frame = 0;
for (int i = 0; i < 36; i++)
{
listOfButtons.Add(new Button());
}
listOfButtons[4 * frame].Width = 92;
listOfButtons[4 * frame].Height = 92;
listOfButtons[4 * frame].BackColor = Color.Red;
listOfButtons[4 * frame].BackgroundImage = System.Drawing.Image.FromFile("image.png");
listOfButtons[4 * frame].BackgroundImageLayout = ImageLayout.Stretch;
listOfButtons[4 * frame].ImageAlign = ContentAlignment.MiddleCenter;
listOfButtons[4 * frame].TextAlign = ContentAlignment.TopCenter;
listOfButtons[4 * frame].Location = new Point(1, 0);
listOfButtons[4 * frame].Click += new EventHandler(this.button1_Click);
listOfButtons[4 * frame + 1].Width = 92;
listOfButtons[4 * frame + 1].Height = 92;
listOfButtons[4 * frame + 1].BackColor = Color.Red;
listOfButtons[4 * frame + 1].BackgroundImage = System.Drawing.Image.FromFile("image.png");
listOfButtons[4 * frame + 1].BackgroundImageLayout = ImageLayout.Stretch;
listOfButtons[4 * frame + 1].ImageAlign = ContentAlignment.MiddleCenter;
listOfButtons[4 * frame + 1].TextAlign = ContentAlignment.TopCenter;
listOfButtons[4 * frame + 1].Location = new Point(1, 99);
listOfButtons[4 * frame + 1].Click += new EventHandler(this.button2_Click);
listOfButtons[4 * frame + 2].Width = 92;
listOfButtons[4 * frame + 2].Height = 92;
listOfButtons[4 * frame + 2].BackColor = Color.Red;
listOfButtons[4 * frame + 2].BackgroundImage = System.Drawing.Image.FromFile("image.png");
listOfButtons[4 * frame + 2].BackgroundImageLayout = ImageLayout.Stretch;
listOfButtons[4 * frame + 2].ImageAlign = ContentAlignment.MiddleCenter;
listOfButtons[4 * frame + 2].TextAlign = ContentAlignment.TopCenter;
listOfButtons[4 * frame + 2].Location = new Point(99, 0);
listOfButtons[4 * frame + 2].Click += new EventHandler(this.button3_Click);
listOfButtons[4 * frame + 3].Width = 92;
listOfButtons[4 * frame + 3].Height = 92;
listOfButtons[4 * frame + 3].BackColor = Color.Red;
listOfButtons[4 * frame + 3].BackgroundImage = System.Drawing.Image.FromFile("image.png");
listOfButtons[4 * frame + 3].BackgroundImageLayout = ImageLayout.Stretch;
listOfButtons[4 * frame + 3].ImageAlign = ContentAlignment.MiddleCenter;
listOfButtons[4 * frame + 3].TextAlign = ContentAlignment.TopCenter;
listOfButtons[4 * frame + 3].Location = new Point(99, 99);
listOfButtons[4 * frame + 3].Click += new EventHandler(this.button4_Click);
listOfButtons[4 * frame].Visible = true;
listOfButtons[4 * frame + 1].Visible = true;
listOfButtons[4 * frame + 2].Visible = true;
listOfButtons[4 * frame + 3].Visible = true;
InitializeComponent();
}
何か案は?