Combo Box Error - DataGridViewComboBoxCell value is not valid RRS feed

  • Question

  • 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



    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 then the error again and so on.


    Does anyone have a suggestion?

    Thursday, October 25, 2007 4:46 PM


All replies

  • I am not sure why the datagridview combobox column does this.  I usually just cancel the dataerror in the datagridview's DataError event if I have a System.ArgumentException error.
    Thursday, October 25, 2007 5:09 PM

    Hi Business_Developer,

    This error occurs when a cell’s value cannot be found in the combo box column’s DataSource or the Items collection. You probably need to add items to the ComboBoxColumn’s item collection or set the DataSource. For more information, check the following page:

    Hope this helps.
    Best regards.
    Rong-Chun Zhang

    Monday, October 29, 2007 12:36 PM

    I've had a problem that maybe it could be similar of your.

    I have a custom collection of my object that I want to set as datasource of a datagridviewcombobox, and I have anoter custom collection of objects, which have a property that refer to the type of the combo.

    This is a problem, because when the user change the value on the combo of an existing row, it always throws the dataerror DataGridViewComboBoxCell value is not valid.


    In the exception, even if in the value member and in the display member there is "Nothing", it says that could not convert string to FormField (where formfield is the name of my class)...and is strange...the only solution I have found is to create in my object binding to combobox, a readonly property "FormFieldRif" which "return me", and after in valueMember i set "FormFieldRif" and so everything works fine...



    I don't know if this could help you





    Saturday, November 24, 2007 12:33 PM
  • Greetings All

    hi there, what will i do to stop this error message, any comments are accepted, tnx

    Best Regards,
    Friday, November 13, 2009 6:23 AM
  • I've run into this issue as well. For the most part I only use the ComboBoxColumn where I have a foreign / primary key relationship which works fine; the issue comes up where I want to use the ComboBox as a helper, rather than to strictly enforce data integrity.

    Is there any way this can be made optional in the future? My case is complicated by the fact the I generate my columns and item lists dynamically. Also I don't like the workaround.. adding an "invalid" value to the drop list is technically wrong. In my case I'd like the user to be able to see the invalid value, but not to be able to select it in the drop list.

    For what it's worth, the code for the above workaround I used is below. I'm not sure it'll work if the DataSource property is used for the drop list. (I populate the Items collection directly).


    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))
          e.ThrowException = false;





    Programmer / Analyst
    Wednesday, October 20, 2010 4:37 PM
  • In the post by Rong-Chun Zhang, he advised to make sure the Items list property has the correct values or that the DataSource property is set and populates the Items list correctly.

    I would like to add that when assigning a value to the .Value property of a DataGridViewComboBox, the mechanism that searches for the value in the Items list does a case-sensitive search.

    If there is not an exact match (case sensitivity as well as spelling), the value will not be found in the list and the System.ArgumentException will be thrown.

    Michael S.

    Monday, November 9, 2015 7:48 PM
  • This apparently can happen when data types don't match.

    I was using a data table. It was backed by SQLite, and one field was numeric (Int64).

    The comboBox entries were populated from a SQL Server, with a data type of Int16. 

    The comboBox started out as NULL, which it was fine with, but as soon as the value was changed with the dropdown it returned this error, apparently unwilling to coerce the Int16 to a Int64. 

    converting the combobox entries to bigint (SQL Server's int64) cleared up the issue.
    • Proposed as answer by Palesius Tuesday, July 23, 2019 12:18 PM
    • Edited by Palesius Tuesday, July 23, 2019 12:19 PM
    Tuesday, July 23, 2019 12:17 PM