日期:2014-05-17  浏览次数:21099 次

C# DataGridView CheckBox单选实现
 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;
        }