- 时间:2022-05-28 10:46 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:实现DataGridView控件中CheckBox列的使用实例
/// <summary>
/// 实现DataGridView控件中CheckBox列的使用
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvTradList_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex != -1)
{
if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
}
else
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
}
}