我正在尝试创建一个 8*8 的网格视图,但列和行没有出现.. 我的代码是这样的..
public static DataGridView[] grid = new DataGridView[30];
public DataGridViewImageColumn col;
grid[i] = new DataGridView();
grid[i].Visible = true;
grid[i].AllowUserToAddRows = false;
grid[i].AllowUserToDeleteRows = false;
grid[i].AllowUserToOrderColumns = false;
grid[i].AllowUserToResizeRows = false;
grid[i].AllowUserToResizeColumns = false;
grid[i].ColumnHeadersVisible = false;
grid[i].RowHeadersVisible = false;
grid[i].Location = new System.Drawing.Point(120,5);
grid[i].Size = new System.Drawing.Size(128, 128);
grid[i].BackgroundColor = Color.SeaShell;
grid[i].GridColor = Color.Green;
grid[i].ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
grid[i].CellBorderStyle = DataGridViewCellBorderStyle.Single;
for (j = 1; j <= 8; j++)
{
col = new DataGridViewImageColumn();
col.Width = 2;
col.ImageLayout = DataGridViewImageCellLayout.Normal;
grid[i].Columns.Add(col);
}
for (k = 1; k <= 8; k++)
{
grid[i].Rows.Add();
}
epnl[i].Controls.Add(grid[i]);
这里 epnl 是一个面板。我正在尝试将每个单元格的高度设置为 2,宽度也设置为 2,但单元格没有出现..我只得到一个空的 datagridview 请帮助