我目前正在尝试使用标签(如Excel工作表)在表格面板上显示多维数组,以显示我必须将数组段分配给特定标签的内容,但如下所示,它& #39;非常繁琐。有什么方法可以让我更容易吗?我知道我可以使用for循环或foreach循环,但不知道如何去做。
第一篇文章,请不要犹豫,指出帖子有什么问题,谢谢:)
int x;
int y;
string output;
string[,] boxes = new string[6,6];
boxes[x, y] = output;
//groupx
Box1.Text = boxes[0, 0];
Box2.Text = boxes[1, 0];
Box3.Text = boxes[2, 0];
Box4.Text = boxes[3, 0];
Box5.Text = boxes[4, 0];
Box6.Text = boxes[5, 0];
//groupx
Box7.Text = boxes[0, 1];
Box8.Text = boxes[1, 1];
Box9.Text = boxes[2, 1];
Box10.Text = boxes[3, 1];
Box11.Text = boxes[4, 1];
Box12.Text = boxes[5, 1];
//groupx
Box13.Text = boxes[0, 2];
Box14.Text = boxes[1, 2];
Box15.Text = boxes[2, 2];
Box16.Text = boxes[3, 2];
Box17.Text = boxes[4, 2];
Box18.Text = boxes[5, 2];
//groupx
Box19.Text = boxes[0, 3];
Box20.Text = boxes[1, 3];
Box21.Text = boxes[2, 3];
Box22.Text = boxes[3, 3];
Box23.Text = boxes[4, 3];
Box24.Text = boxes[5, 3];
//groupx
Box25.Text = boxes[0, 4];
Box26.Text = boxes[1, 4];
Box27.Text = boxes[2, 4];
Box28.Text = boxes[3, 4];
Box29.Text = boxes[4, 4];
Box30.Text = boxes[5, 4];
//groupx
Box31.Text = boxes[0, 5];
Box32.Text = boxes[1, 5];
Box33.Text = boxes[2, 5];
Box34.Text = boxes[3, 5];
Box35.Text = boxes[4, 5];
Box36.Text = boxes[5, 5[;