DataGridViewComboBoxCell value is not valid
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: DataGridViewComboBoxCell value is not valid

  1. #1
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    DataGridViewComboBoxCell value is not valid

    Using VS2010 and VS2008

    I have a DataGridView bound to a DataTable which has an Int16 DataColumn. The DGV has a DataGridViewComboBoxColumn tied to the DataColumn.

    I enter integer values in the Items section of the DGVCBColumn properties. When I run the program I get "DataGridViewComboBoxCell value is not valid".

    I assume this is because my Items are text and the data column is integer so I created a List of Integer, added my integer values/choices to the list and made the List my data source for the ComboBox column. Same error.

    I then created another DT in the DS with one column type Int16, added my integer choices to the DT, created a BS for the ChoicesDT and set this BS as the DataSource, the column as the DisplayMember and the ValueMember. Same error.

    There are no issues like this when the DataColumn is bound to a ComboBox outside of the DGV so I assume there is some issue with the DGV understanding the underlying binding.

    I have read some solutions that include trapping and discarding the error but would like something cleaner if anyone has it.

    thx

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,987

    Re: DataGridViewComboBoxCell value is not valid

    Show us your code...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Oct 2010
    Posts
    1

    Wink Re: DataGridViewComboBoxCell value is not valid

    Try to set AutoSizeColumnsMode to none

  4. #4
    Join Date
    Apr 2012
    Posts
    1

    Smile Re: DataGridViewComboBoxCell value is not valid

    Hi Wirah,

    That worked for me!

    You saved me a LOT of time with this fix, I would never have thought to change the AutoSizeColumnsMode, as I thought it was an error relating to the content of the databinding.

    Also worth noting that you can also use the "Fill" AutoSizeColumnsMode. (Probably because those modes are not data-dependant).

    Thanks again,

    Wodge

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center