I have a datagridview (bound to a DataTable) that has a combobox column (bound to bindingsource). Inserting data is not a problem. The problem occurs when I edit a row the datagridview throws an exception "datagridviewcomboboxcell value is not valid". The DGV combobox turns blank afterwards.
I posted this code to the DGV DataError Event to find the exact error:
I got this error "Error happened formatting, Display" and after I click ok I get this error "Error happened formatting, preferred Size".Code:If (e.Context = DataGridViewDataErrorContexts.Commit) Then MessageBox.Show("Commit error") End If If (e.Context = DataGridViewDataErrorContexts.CurrentCellChange) Then MessageBox.Show("Cell change") End If If (e.Context = DataGridViewDataErrorContexts.Parsing) Then MessageBox.Show("parsing error") End If If (e.Context = DataGridViewDataErrorContexts.LeaveControl) Then MessageBox.Show("leave control error") End If If (TypeOf (e.Exception) Is ConstraintException) Then Dim view As DataGridView = CType(sender, DataGridView) view.Rows(e.RowIndex).ErrorText = "an error" view.Rows(e.RowIndex).Cells(e.ColumnIndex).ErrorText = "an error" e.ThrowException = False End If
I'm stuck. Can't figure out what I am doing wrong?




Reply With Quote
