Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:53:35+00:00 2026-06-12T23:53:35+00:00

I have a DataGridView with a DataGridViewComboBoxColumn in the first column that is bind

  • 0

I have a DataGridView with a DataGridViewComboBoxColumn in the first column that is bind whith a List<MyClass> and a DisplayMember="name" (I dont set the valeumember because i want to get myclass when I accesse to value). The second column is a DataGridViewComboBoxColumn too. It will be bound to some List<String> based on the first DataGridViewComboBoxColumn selectedValue.

All this work just fine, the problem starts when I change the first DataGridViewComboBoxColumn.DataSource. When I add a new Myclass to the datasource it works, but if I select the class I will get an error:

System.ArgumentException: DataGridViewComboBoxCell value is not valid

Code:

//Set columns to Datagridview  
DataGridViewImageColumn btnEdit = new DataGridViewImageColumn();  
Image gear = (System.Drawing.Image)Properties.Resources.gear;  
btnEdit.Image = gear;  
datagridview.Columns.Add(btnEdit);  

//Table  
DataGridViewComboBoxColumn cbTable = new DataGridViewComboBoxColumn();  
cbTable.HeaderText = "Table";  
cbTable.Name = "Table";  
cbTable.DisplayMember = "NameToShow";  
//tableDataSource = cbTable.DataSource;  
//cbTable.DataSource = moduleClone.SqlQuery.Tables;  
datagridview.Columns.Add(cbTable);  

//...  
//...  
//...  

//Load data  
((DataGridViewComboBoxColumn)datagridview.Columns[1]).DataSource = (List<Table>)moduleClone.SqlQuery.Tables;  
//Work just fine  

//...  
//...  
//...  

//Now if i reload de data  
datagridview.Rows.Clear();  
((DataGridViewComboBoxColumn)datagridview.Columns[1]).DataSource = (List<Table>)moduleClone.SqlQuery.Tables;  
//This give me one message box with the exception several times when drawing the gridview.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:53:36+00:00Added an answer on June 12, 2026 at 11:53 pm

    Ok, I found a solution that works for me.
    Instead use DataGridViewComboBoxColumn.DataSource, I directly change DataGridViewComboBoxColumn.Items. Has a probleme because you cant change DataGridViewComboBoxColumn.Items if DataGridViewComboBoxColumn.DataSource is set. So I define DataGridViewComboBoxColumn.DataSource = null before edit DataGridViewComboBoxColumn.Itens.

    Code:

    //Set columns to Datagridview  
    DataGridViewImageColumn btnEdit = new DataGridViewImageColumn();  
    Image gear = (System.Drawing.Image)Properties.Resources.gear;  
    btnEdit.Image = gear;  
    datagridview.Columns.Add(btnEdit);  
    
    //Table  
    DataGridViewComboBoxColumn cbTable = new DataGridViewComboBoxColumn();  
    cbTable.HeaderText = "Table";  
    cbTable.Name = "Table";  
    cbTable.DisplayMember = "NameToShow";  
    datagridview.Columns.Add(cbTable);  
    
    //...  
    //...  
    //...  
    
    //Load data  
    ((DataGridViewComboBoxColumn)datagridview.Columns[1]).Itens = (List<Table>)moduleClone.SqlQuery.Tables;  
    //Work just fine  
    
    //...  
    //...  
    //...  
    
    //Now I reload de data  
    datagridview.Rows.Clear();
    ((DataGridViewComboBoxColumn)datagridview.Columns[1]).DataSource = null; 
    ((DataGridViewComboBoxColumn)datagridview.Columns[1]).Items.clear();
    ((DataGridViewComboBoxColumn)datagridview.Columns[1]).Items= (List<Table>)moduleClone.SqlQuery.Tables;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second
I have datagridview with checkbox column, but I want, that some of the columns
I have tables like that in Datagridview: Name Money ------------- Hi 100 //here Combobox
I have a DataGridView with a few DataGridViewComboBoxColumn's. The columns have their DataSource set
I currently have a 2-column wide DataGridView, the first column being a DataGridViewTextBoxColumn and
I have a DataGridView that displays a list of MMS Messages. To differentiate between
I have a standard DataGridView , and my last column is a DataGridViewComboBoxColumn .
I have a datagridview that has set colors depending on the status of the
I have DataGridView whith Column of comboboxes. I have to click twice the cell
I have a datagridview with a DataGridViewComboboxColumn column with 3 values: Small, Medium, Large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.