Problem with value DataGridViewComboBoxCell

In VB 2005 Express I have a problem, which completely do not understand. I use a DataGridViewComboBox in a DataGridView. When I change data and save it, I have no problem. But when I close the form I a repeting error, being: System.ArgumentException: DataGridViewComboBoxCell value is not valid.

Can anybody help

Thanks in advance,
Simon


Answer this question

Problem with value DataGridViewComboBoxCell

  • max_08

    Yes, the save works fine and also actually saves.

    My data is coming from a table and the display member and value member are different fields.

    But now it has become even more strange. I don't know what I changed, but the error is gone. So for now I'm OK, but when it happens again, I don't know how to solve this.

    Regards,
    Simon

  • Blake Bishop

    I have the same problem and it is becoming a little frustrating. I have not even changed anything on the particular form that is throwing the error.
  • dsinay

    Mark,

    Thanks for the workaround.

    I don't mind filing a bug, but where can I do that. When VBE was still beta there where some links to bugs and suggestion forums, but I can't find those anymore.

    Regards,
    Simon

  • jordan kaliher

    Does the data you saved exist in the DataGridViewComboBoxCell's items list

    For instance, if your DataGridViewComboBoxCell::Items collection is {"one", "two", "three" } and the value you saved is "four" then you will get this error.

    Another situation is if your DataGridViewComboBoxCell is data bound. For example sake, say that the ComboBox displays data from a DataTable, say it displays data from the DataColumn "Number".  If the DataColumn contains  "one", "two", and "three" and the value you saved is "four" then you will also get this error.

    Hope this helps,
    Daniel.



  • Dinesh Asanka

    Thanks for the suggestion.
    I have solved it by deleting the DGV and created a new one, with the same combobox. Since then I didn't have the issue anymore.

  • Jens Hibbeler

    Mark,

    That sounds resonable. But I receive the error while closing the form.

    Simon

  • Sanjuz

    Right now I'd say that you'll want to remove the autosizing in the grid's dispose event or in the form's closing event. < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     

    Can you file a bug for this This will help us identify what is going on here.

     

    thanks,

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"

     


  • stoneyowl

    And the problem is back again. I have changed nothing to that field. I was making some other changes to the form and then the problem was there and disappeared again. But also surfaced again. I realy don't understand this.

    Any suggestions

    Regards,
    Simon

  • ETopGun

    I have now found what caused the issue. When I turn the autosizemode for a DataGridViewComboBoxColumn on, I will get the error. When I turn it off, I have no problem.

    Regards,
    Simon

  • Fiofio38

    If you autosize the column but have not provided the combo box column with a valid datasource or you haven't yet added items to the combo box column's items collection then you'll get this error at startup because autosizing requires the cell's FormattedValue to be requested. Requesting the FormattedValue of a combo box cell is where the check is done that may raise the data error exception you are seeing.

    Set the autosize mode after you fill the combo box and things should be ok.

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"

  • e-an

    So the combobox's items contain the value that you save -  see my previous post

    If you have a sample app can you post it here Also, can you post what value you save the combobox to

    Thanks,
    Daniel.

  • Abu14166

    Done
  • bbakermai

    I found a work around. If I take out the databindings for the grid before closing the form I don't get the error.



    Me
    .dgvStoreVisit.DataSource = Nothing
    Me.Close()

     



  • Vincent Reynolds

    Use the following link: http://lab.msdn.microsoft.com/productfeedback/Default.aspx < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     

    -mark

    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"

     


  • Problem with value DataGridViewComboBoxCell