【发布时间】:2017-11-13 00:58:30
【问题描述】:
有人知道如何使用二维数组以编程方式生成复选框like this 的网格吗?
for (int x = 0; x < numberOfRows; x++)
{
for (int y = 0; y < numberOfColumns; y++)
{
int index = x * numberOfColumns + y;
var checkbox = new CheckBox();
checkbox.Location = new Point(20 * x, 20*y);
this.Controls.Add(checkbox);
}
}
【问题讨论】:
-
CheckBox[,] c = new CheckBox[10,10]; for (int i = 0; i < c.GetLength(0); i++) { for (int j = 1; j < c.GetLength(1); j++) { c[i,j] = new CheckBox(); c[i, j].Location = new Point(5, i * 20); this.Controls.Add(c[i, j]); } } -
你在使用 WPF 吗?
-
不只是 Windows 窗体
-
您是否考虑过
DataGridView充满了复选框列?
标签: c# arrays checkbox datagridview