在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);
}
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/netgyc/archive/2009/12/28/5089318.aspx