我将我的数据网格视图有如下
我想只有在BatchHeader复选框和EntryDetail的是有可能的。这是我的方式将数据绑定到数据网格视图RecordTypeCode Content
FileHeader 1111111111111
BatchHeader 5666666666666
EntryDetail 656546545644545
BatchControl 8654654564564
FileControl 945645
{C}
我想添加复选框为需要的任何一个可以帮助我,我尝试不同的方式
但是我相应的行出现空当,我只检查为BatchHeader
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
if (dataGridView2.Rows[e.RowIndex].Cells["RecordTypeCode"].Value.ToString() == "BatchHeader")
{
e.PaintBackground(e.ClipBounds, true);
e.Handled = true;
}
}
int columnIndex = -1;
int rowIndex = -1;
if (dataGridView2.CurrentCell != null)
{
columnIndex = dataGridView2.CurrentCell.ColumnIndex;
rowIndex = dataGridView2.CurrentCell.RowIndex;
}
if (columnIndex == 0)
{
if (e.RowIndex >= 0)
{
if (dataGridView2.Rows[e.RowIndex].Cells["RecordTypeCode"].Value.ToString() == "Batch Header")
{
e.PaintBackground(e.ClipBounds, true);
e.Handled = true;
}
}
}