c#dataGridView的属性CellPainting隐藏单元格的值
dataGridView的属性
隐藏单元格的值
CellPainting
private void dataGridView_front_section_storage_09_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { //隐藏单元格的值 // if (e.ColumnIndex != dataGridView_front_section_storage_09.Columns["c1"].Index) //"c1" column1的title //c6:第5个先边仓储位对应 if (e.ColumnIndex == dataGridView_front_section_storage_09.Columns["c6"].Index || e.ColumnIndex == dataGridView_front_section_storage_09.Columns["c7"].Index || e.ColumnIndex == dataGridView_front_section_storage_09.Columns["c8"].Index || e.ColumnIndex == dataGridView_front_section_storage_09.Columns["c9"].Index ) { //string description = "something"; if (e.Value != null) { // if (e.Value.ToString() == description) if (e.Value.ObjToInt() >= 0) { e.CellStyle.ForeColor = e.CellStyle.BackColor; e.CellStyle.SelectionForeColor = e.CellStyle.SelectionBackColor; } } } }
欢迎讨论,相互学习。
cdtxw@foxmail.com