实现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;
}
}

本文实现DataGridView控件中CheckBox列的使用实例到此结束。有时稍微低下头,或许我们人生路会更加精彩,我们的能力也会有所长进。小编再次感谢大家对我们的支持!