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 381693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:06:37+00:00 2026-05-12T15:06:37+00:00

I have a DataGridView with custom columns. But when I add a DataGridViewComboBoxColumn and

  • 0

I have a DataGridView with custom columns.

But when I add a “DataGridViewComboBoxColumn” and give to it a list of my model class as DataSource then I had the following error:

System.ArgumentException:
DataGridViewComboBoxCell value is not
valid.


New EDIT: 4/9/2009 “More Details”

I’ve a class called SmsPart has these properties:

public class SmsPart
{
    public int ID
    public SmsPart Parent
    public string Name
    // and more
}

I’ve method called “GetSmsParts” return “List<SmsPart>“.

I want the Parent column in the DataGridView to be ComboBoxColumn to select which part is the parent of selected part.

So for that reason I made “DataGridViewComboBoxColumn” and set it’s Datasource the same DataSource for the hole DataGridView “Which is the GetsmsParts method“:

    DataGridViewComboBoxColumn comboCulomn = new DataGridViewComboBoxColumn();
    comboCulomn.DataSource = listParts;
    comboCulomn.DataPropertyName = "Parent";
    comboCulomn.DisplayMember = "Name";
    comboCulomn.ValueMember = "ID";
    comboCulomn.Name = "Parent";
    dgvParts.Columns.Add(comboCulomn);

But i always have this error message:

System.ArgumentException:
DataGridViewComboBoxCell value is not
valid.

  • 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-05-12T15:06:37+00:00Added an answer on May 12, 2026 at 3:06 pm

    try assigning the name of the datafield for the ValueMember property of clm2. While you’re specifying that the value type is typeof(smsType), you’re not telling the ComboBox column which field to use for the value.

    EDIT
    Wait a second: Is your smsType some complex type or something? I’m not sure if any restrictions apply here, but for a sample you should use something like int or string or so (anything you’d normally expect to be stored as a database field).

    Also, of course, the type of the DataGridView‘s underlying data source’s column (in your example called “Type”) must also be of the same type as the ValueMember!

    EDIT 2
    On your second comment: Imagine a database table called “tbl” that contains (among others) one column called “Type” that is of type Integer. You’re displaying the contents of that table in your DataGridView and you want the user to be able to select values for the “Type” column from a combo box. This is about the scenario you’re talking about.

    1. it is not possible to store complex types in like the one you’re using in database columns, so you can not use complex types for the Value field in a DataGridViewComboBoxColumn.
    2. To perform the data binding for the entire grid, you must bind the grid to the database table “tbl”. To create the DataGridViewComboBoxColumn, you need to assign a list of possible values to the column and tell the column the field in the DataGridView’s datasource it stores the selected value to, which field is used as a display value and which field is used as the value that is stored in the underlying datasource’s column.

    That means in the sample (assuming the data source for the column contains properties “Value” and “Name”):

    DataGridViewComboBoxColumn col = new ...
    col.DataSource = columnDataSource;
    col.DisplayMember = "Name";
    col.ValueMember = "Value";
    col.DataPropertyName = "Type";
    

    This is all. However, the type of the property you assign to “ValueMember” can not be a complex type (class/struct) if I recall correctly…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Perhaps it will help to have a working example. Here's… May 13, 2026 at 10:06 pm
  • Editorial Team
    Editorial Team added an answer Reading here (Goto SQL Server 2000 Support near the bottom)… May 13, 2026 at 10:06 pm
  • Editorial Team
    Editorial Team added an answer "Does ** have any special meaning in C?" No, it… May 13, 2026 at 10:06 pm

Related Questions

I have a list of objects (of type 'TrackedSet') that is data bound to
I seem to be running around in circles and have been doing so in
I have a DataSet that contains a few columns. One of these columns is
I have a helper class that implements ITypedList, to provide objects for databinding against

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.