In DataGridView CheckBox implements a single column

  • 2020-05-26 08:12:43
  • OfStack


private void dgvChannel_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == -1 || e.RowIndex == -1) return;
            int x = dgvChannel.CurrentCell.ColumnIndex;// Gets the click column of the mouse 
            if (x == 0)// Click on the first 1 The columns are single. 
            {
                for (int i = 0; i < dgvChannel.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)dgvChannel.Rows[i].Cells[0];
                    checkcell.Value = false;
                }
                DataGridViewCheckBoxCell ifcheck = (DataGridViewCheckBoxCell)dgvChannel.Rows[e.RowIndex].Cells[0];
                ifcheck.Value = true;
            }
        }        

Related articles: