0

So I have a DataGridView with one column set to type ComboBox. When I add a new row, I populate the combobox for the cell like so:

foreach (Job cJob in cJobs)
{
    cbItem = new ComboboxItem();
    cbItem.Text = cJob.Name;
    cbItem.Value = cJob.Name;
    Object oCell = dgItem.Cells[1];
    oComboxCell = (DataGridViewComboBoxCell)oCell;
    oComboxCell.Items.Add(cbItem);
}

I then set the value of the cell as normal:

dgItem.Cells[ColumnIndexes.IND_ENTRIES_JOB].Value = cboJob.SelectedItem;

For all intents and purposes the value is indeed set to what I set it to, but on the screen the combo box is visible on top and the first item in the combo is what's displayed as the value! What could be causing this? I'm sure it's worked in the past.

Jay Croghan
  • 445
  • 3
  • 16
  • cbItem doesn't have a SelectedIndex – Jay Croghan Sep 15 '16 at 20:48
  • There are actually plenty of examples on the web in regards to adding a ComboBox to a DataGridView also look at this alternative posting http://stackoverflow.com/questions/11900502/adding-combobox-to-a-datagridview-for-a-particular-row – MethodMan Sep 15 '16 at 21:32

0 Answers0