在Winform中,DataGridVIEw中使用Checkbox控件時
//單擊單元格事件
PRivate void dgvTables_CellClick(object sender, DataGridVIEwCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
DataGridViewCheckBoxCell dgvCheck = (DataGridVIEwCheckBoxCell)dgvTables.Rows[e.RowIndex].Cells[0];
if (dgvCheck.Selected)
{
dgvCheck.Value = !((bool)dgvCheck.FormattedValue);
}
}
}