Author Topic: Problem to fill DatagridviewComboBoxCell  (Read 148 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 151
Problem to fill DatagridviewComboBoxCell
« on: September 03, 2020, 04:18:16 PM »
HI,

I have a treeview and a datagridview.  The datagridview is bind to a datatable and I have add a DataGridviewComboBoxCell.

When I check an item on my treeview, the datagridview is update.  It work fine except for the first item checked.

The DataGridviewComboBoxCell is not fill properly.  When I debug, I see that my list (lst in the code below) contains the correct value and it seem to add it correctly but it's not the case. 

The ComboboxCell will fill correctly for all the other item checked.  If I uncheck the first item and check again, the value in the combobox will be correct.

Code: [Select]
DataGridViewComboBoxCell dgvcbc = (DataGridViewComboBoxCell)dgvBlocs.Rows[nRow].Cells["Visibilité New"];                                               
dgvcbc.Items.Clear();
foreach (object itemToAdd in lst)
{
      dgvcbc.Items.Add(itemToAdd);
}

I'm lost on that one !

Thank you in advance