好的,我用这段代码创建了一个棋盘:
int numBlocks = 8;
Panel[,] chessBoardPanels = new Panel[numBlocks, numBlocks];
for (int iRow = 0; iRow < numBlocks; iRow++)
for (int iColumn = 0; iColumn < numBlocks; iColumn++)
{
Panel p = new Panel();
//set size
p.Size = new Size(50, 50);
//set back colour
p.BackColor = (iRow + (iColumn % 2)) % 2 == 0 ? Color.Black : Color.White;
//set location
p.Location = new Point(50 * iRow, 50 * iColumn);
chessBoardPanels[iRow, iColumn] = p;
groupBox1.Controls.Add(p);
}
当我使用命令时:
chessBoardPanels[1,1].BackColor=Color.Red;
面板会改变颜色,但是我将如何使用数组创建像鼠标输入这样的事件??????