Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Combo Box Error - DataGridViewComboBoxCell value is not valid

Combo Box Error - DataGridViewComboBoxCell value is not valid

Scheduled Pinned Locked Moved Windows Forms
databasehelpquestion
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    basi0014
    wrote on last edited by
    #1

    I am trying to get the Combo Box working so that i can get the drop-down boxes available for the database columns to be placed in the DataGridView. But i am getting the following error when the data displays in the DataGridView The following exception occurred in the DataGridView: System.ArgumentException: DataGridViewComboBoxCell value is not valid. To replace this default dialog please handle the DataError event Background: The way i am selecting the 'Column Type' is through the Designer. So i can choose the DataGridViewTextBoxColumn or DataGridViewComboBoxColumn The dataGridView is hooked up to a bindingSource and I have my bindingSource wired to a List Object. There is a dataTime picker control on the form, which is used to pull the data. When i choose the DataGridViewTextBoxColumn, the data displays perfect. But when i change the 'Column Type' to DataGridViewComboBoxColumn, running the form gives the error repeatedly and as i click on each error, one row of data displays and so on. Does anyone have a suggestion?

    J N 2 Replies Last reply
    0
    • B basi0014

      I am trying to get the Combo Box working so that i can get the drop-down boxes available for the database columns to be placed in the DataGridView. But i am getting the following error when the data displays in the DataGridView The following exception occurred in the DataGridView: System.ArgumentException: DataGridViewComboBoxCell value is not valid. To replace this default dialog please handle the DataError event Background: The way i am selecting the 'Column Type' is through the Designer. So i can choose the DataGridViewTextBoxColumn or DataGridViewComboBoxColumn The dataGridView is hooked up to a bindingSource and I have my bindingSource wired to a List Object. There is a dataTime picker control on the form, which is used to pull the data. When i choose the DataGridViewTextBoxColumn, the data displays perfect. But when i change the 'Column Type' to DataGridViewComboBoxColumn, running the form gives the error repeatedly and as i click on each error, one row of data displays and so on. Does anyone have a suggestion?

      J Offline
      J Offline
      jitender parnami
      wrote on last edited by
      #2

      This error occured when datagrid column value not match with combobox colloection items.this error can be handle on datagrid dataerror events. void view_DataError(object sender, DataGridViewDataErrorEventArgs e) { if (e.Exception.Message == "DataGridViewComboBoxCell value is not valid.") { object value = view.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; if (!((DataGridViewComboBoxColumn)view.Columns[e.ColumnIndex]).Items.Contains(value)) { ((DataGridViewComboBoxColumn)view.Columns[e.ColumnIndex]).Items.Add(value); e.ThrowException = false; } } } Jitender Parnami

      1 Reply Last reply
      0
      • B basi0014

        I am trying to get the Combo Box working so that i can get the drop-down boxes available for the database columns to be placed in the DataGridView. But i am getting the following error when the data displays in the DataGridView The following exception occurred in the DataGridView: System.ArgumentException: DataGridViewComboBoxCell value is not valid. To replace this default dialog please handle the DataError event Background: The way i am selecting the 'Column Type' is through the Designer. So i can choose the DataGridViewTextBoxColumn or DataGridViewComboBoxColumn The dataGridView is hooked up to a bindingSource and I have my bindingSource wired to a List Object. There is a dataTime picker control on the form, which is used to pull the data. When i choose the DataGridViewTextBoxColumn, the data displays perfect. But when i change the 'Column Type' to DataGridViewComboBoxColumn, running the form gives the error repeatedly and as i click on each error, one row of data displays and so on. Does anyone have a suggestion?

        N Offline
        N Offline
        Narayan MCA
        wrote on last edited by
        #3

        In C#.net You should handle data error event of the datagridview private void grdGuestServiceDetail_DataError(object sender, DataGridViewDataErrorEventArgs e) { if(e.Context== (DataGridViewDataErrorContexts.Formatting) || e.Context==(DataGridViewDataErrorContexts.PreferredSize)) { e.ThrowException = false; } } and In VB.net Private Sub DataGridView_DataError(ByVal sender As Object, ByVal e As DataGridViewDataErrorEventArgs) If (e.Context _ = (DataGridViewDataErrorContexts.Formatting Or DataGridViewDataErrorContexts.PreferredSize)) Then e.ThrowException = false End If

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups