private void dgvCustomerCellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == -1 || e.RowIndex == -1) return;
for (int i = 0; i < dgvMaterial.Rows.Count; i++)
{
DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)dgvMaterial.Rows[i].Cells[0];
checkcell.Value = false;
}
DataGridViewCheckBoxCell ifcheck = (DataGridViewCheckBoxCell)dgvMaterial.Rows[e.RowIndex].Cells[0];
ifcheck.Value = true;
}
C# DataGridView CheckBox单选实现
最新推荐文章于 2024-06-28 10:01:50 发布
本文介绍了一个关于DataGridView控件的单元格点击事件处理方法。该方法实现了当点击某一行时,清除所有行的选择状态,并仅选中被点击的行。此功能常用于单选或多选场景。
3059

被折叠的 条评论
为什么被折叠?



