我有一個問題,我找不出來。DataGridViewComboboxCell.Value上的FormatException
我有一個的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";
當選項「Klant aanvraag」被選中的用戶得到一個窗口,用戶可以在其中選擇其他客戶。 這是由於用戶未被分配給該客戶的特定項目的原因。 當用戶選擇一個時,它將在Combobox中用以下代碼進行更改。
uxUrenInvoeren[collumnIndex, row.Index].Value = uxInvoerenKlant.Items[klantIndex];
klantindex
是需要被選擇的客戶的,因爲它是從組合框中檢索。我認爲這是正確的一種對象。
在此之後,datagridview_dataerror
事件引發哪裏出現以下異常文本格式例外。
DataGridViewComboBoxCell值無效。
什麼問題?
你幾乎對,uxUrenInvoeren [collumnIndex,row.Index] .value的是-1,但這不是問題。我發佈的方式,它被解決爲答案 –