我正在嘗試創建一個.txt
文件,我可以用我的程序打開該文件,並通過分割將它們保存在兩個不同數組中的所有數字。 但由於某種原因,頂部零件不會更改BackColor
。無法更改圖片框陣列的背景色
這裏是代碼:
PictureBox[,] Field = new PictureBox[4, 4];
int[,] Block_Property = new int[4, 4];
for (int x = 0; x < 4; x++)
{
for (int y = 0; y < 4; y++)
{
Field[x, y] = new PictureBox();
Field[x, y].Size = new Size(64, 64);
Field[x, y].Location = new Point(x * 64, y * 64);
this.Controls.Add(Field[x, y]);
}
}
string Text;
int Zahler=0;
using (StreamReader sr = new StreamReader("Level/1-1.txt"))
{
Text = sr.ReadToEnd();
}
string[] Feld = Text.Split(';');
for(int x = 0; x < 4; x++)
{
for(int y = 0; y < 4; y++)
{
if(Feld[Zahler] == "1")
{
Field[x, y].BackColor = Color.Black;
}
Zahler++;
if (Feld[Zahler] == "1")
{
Block_Property[x, y] = 1;
}
Zahler++;
}
}
這是怎麼了我的.txt
文件如下:
1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;
這裏是如何照顧我啓動程序:
現在3個白Pictureboxes是一個左側的不是頂部 – Dolfos