DataGridView中CheckBox实现单选

 private void totalDataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
                if (e.ColumnIndex == -1 || e.RowIndex == -1) return;
                for (int i = 0; i < totalDataGridView1.DataGrid.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)totalDataGridView1.DataGrid.Rows[i].Cells[0];
                    checkcell.Value = false;
                }
                DataGridViewCheckBoxCell ifcheck = (DataGridViewCheckBoxCell)totalDataGridView1.DataGrid.Rows[e.RowIndex].Cells[0];
                ifcheck.Value = true;
        }

你可能感兴趣的:(WinForm,object)