dataGridView DataGridViewCheckBoxColumn 列的选择与反选择
注意设置 DataGridViewCheckBoxColumn 列的TrueValue 和 FalseValue 值分别为 true,false
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex!=-1)
{
bool t = false;
if (this.dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
{
t = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()=="true"?true:false;
t = !t;
this.dataGridView1.Rows[e.RowIndex].Cells[0].Value = t;
}
}
}
{
if (e.RowIndex!=-1)
{
bool t = false;
if (this.dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
{
t = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()=="true"?true:false;
t = !t;
this.dataGridView1.Rows[e.RowIndex].Cells[0].Value = t;
}
}
}