I have a problem which I can't figure out.
I have an DataGridViewComboboxCell,
List<ComboBoxItem> klanten = new List<ComboBoxItem>();
foreach (ICustomer customer in CustomerFactory.CreateCustomers())
{
klanten.Add(new ComboBoxItem(customer.Naam, customer.Id));
}
klanten.Add(new ComboBoxItem("Klant aanvraag", -1));
uxInvoerenKlant.DataSource = klanten;
uxInvoerenKlant.DisplayMember = "Text";
uxInvoerenKlant.ValueMember = "Value";
When the option "Klant aanvraag" is selected the user gets a window where the user can choose another customer. This is for the reason the user was not assigned for a specific project for that customer. When the user chose one it will be changed in the Combobox with the following code.
uxUrenInvoeren[collumnIndex, row.Index].Value = uxInvoerenKlant.Items[klantIndex];
klantindex
is the customer that needs to be selected, because it is retrieved from the combobox. It is the right kind of object in my opinion.
After this, the datagridview_dataerror
event is raised where I get the Format exception with the following exception text.
DataGridViewComboBoxCell value is not valid.
What is the problem?