【发布时间】:2018-08-14 21:20:19
【问题描述】:
我将控件添加到表单中由它们在数组中的位置指定的位置。我已尝试将面板切换为按钮,但控件仍未显示。
int[,] gamefield = new int[9, 8];
Panel[,] vis_gamefield = new Panel[9, 8];
private void Real_Move(int col)
{
for (int i = 6; i > 0; i--)
{
gamefield[col, i] = 1;
vis_gamefield[col, i] = new Panel();
vis_gamefield[col, i].Name = "Panel" + moves;
vis_gamefield[col, i].BackColor = Color.Red;
vis_gamefield[col, i].Size = new Size(88, 88);
vis_gamefield[col, i].Location = new Point(158 + 100 * (i - 1), 174 + 99 * (col - 1));
vis_gamefield[col, i].Visible = true;
vis_gamefield[col, i].BringToFront();
vis_gamefield[col, i].Show();
Win_Check(col, i);
moves++;
break;
}
}
【问题讨论】:
-
I'm adding controls onto my form不,您似乎忘记向控件集合添加任何内容 -
您忘记将面板添加到父级,考虑
this.Controls.Add(vis_gamefield[col, i]);