Results 1 to 9 of 9

Thread: [RESOLVED] Help Datagridview error: datagridviewcomboboxcell value is not valid?

Threaded View

  1. #1

    Thread Starter
    Addicted Member coolwater's Avatar
    Join Date
    Dec 2004
    Location
    philippines
    Posts
    215

    Resolved [RESOLVED] Help Datagridview error: datagridviewcomboboxcell value is not valid?

    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:

    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 got this error "Error happened formatting, Display" and after I click ok I get this error "Error happened formatting, preferred Size".

    I'm stuck. Can't figure out what I am doing wrong?
    Last edited by coolwater; Nov 15th, 2013 at 03:34 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width