A column with a checkbox type has been added to the grid. Everything is displayed fine, but when you click on the checkbox, it is not marked. What could be the problem?

dg_drive.DataSource = core.GetListDriver(pid); dg_drive.AllowUserToAddRows = false; dg_drive.RowHeadersVisible = false; DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn(); cb.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; cb.ToolTipText = "Выбрать водителя"; cb.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; cb.FlatStyle = FlatStyle.System; cb.DataPropertyName = "sel_driver"; dg_drive.Columns["id"].Visible = false; dg_drive.Columns["fio"].HeaderText = "ФИО Водителя"; dg_drive.Columns["truck_name"].HeaderText = "Траснспорт"; dg_drive.Columns["truck_num"].HeaderText = "Гос.номер"; dg_drive.Columns["trailer_num"].HeaderText = "П/п гос.номер"; dg_drive.Columns.Add(cb); dg_drive.Columns[6].Width = 30; dg_drive.Columns[6].DisplayIndex = 0; dg_drive.Columns[1].DisplayIndex = 1; dg_drive.Columns[2].DisplayIndex = 2; dg_drive.Columns[3].DisplayIndex = 3; dg_drive.Columns[4].DisplayIndex = 4; 

    1 answer 1

    You probably do not allow editing the DataGridView as a whole. Add

     private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex == 6) dataGridView1[e.ColumnIndex, e.RowIndex].Value = !(bool)dataGridView1[e.ColumnIndex, e.RowIndex].Value; } 

    poser must go