私にはわからない問題があります。DataGridViewComboboxCell.ValueのFormatException
私はDataGridViewComboboxCell、オプション「Klantのaanvraagは、」ユーザが別の顧客を選択することができ、ウィンドウを取得し、選択された
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";
を持っています。 これは、ユーザーがその顧客の特定のプロジェクトに割り当てられていないためです。 ユーザーが1つを選択すると、次のコードでComboboxで変更されます。
uxUrenInvoeren[collumnIndex, row.Index].Value = uxInvoerenKlant.Items[klantIndex];
klantindex
それはコンボボックスから取得されるので、選択する必要のある顧客です。私の意見では、それは正しい種類のオブジェクトです。
この後、datagridview_dataerror
イベントが発生し、次の例外テキストを含むFormat例外が発生します。
DataGridViewComboBoxCellの値が無効です。
何が問題ですか?
あなたは、ほぼ正しかった、uxUrenInvoeren [collumnIndex、row.Index] .Valueの-1であったが、これは問題ではありませんでした。私はそれが答えとして解決される方法を投稿しました –