C# 隐藏datagridview单元格问题 <紧急求助>
在datagridview中单元格的值有的为1,有的为空,我现在想隐藏掉值为空的单元格,禁止对值为空的单元格操作,应该怎么做?
------解决方案-------------------- private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.Value == null)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = true;
}
}
------解决方案--------------------C# code
for (int i = 0; i < dgv_Meet.Rows.Count; i++)
{
for (int k = 0; k < dgv_Meet.Columns.Count; k++)
{
if (dgv_Meet.Rows[i].Cells[k].Value == null)
dgv_Meet.Rows[i].Cells[k].ReadOnly = true;
}
}