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

  • Home
  • SEARCH
  • 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 852205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:33:23+00:00 2026-05-15T07:33:23+00:00

I have this problem: I have a datagridview that reads the data from a

  • 0

I have this problem:
I have a datagridview that reads the data from a db and I wish, for an integer column use a combobox to choose some values…
I modified the column using DataGridViewComboBoxColumn type and after, on the init of the form this:

DataTable dt = new DataTable("dtControlType");
dt.Columns.Add("f_Id");
dt.Columns.Add("f_Desc");
dt.Rows.Add(0, "none");
dt.Rows.Add(1, "value 1");
dt.Rows.Add(2, "value 2");
dt.Rows.Add(3, "value 3");

pControlType.DataSource = dt;
pControlType.DataPropertyName = "pControlType";
pControlType.DisplayMember = "f_Desc";
pControlType.ValueMember = "f_Id";

but when the program starts (after this code) this message appears:
error http://www.ghiboz.info/shots/4a4fe5fd.png

  • 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-15T07:33:23+00:00Added an answer on May 15, 2026 at 7:33 am

    solved by myself: here is the solution:

    public class HGrid
    {
        public static void MakeComboBoxColumn(ref DataGridViewComboBoxColumn col, List<string> values)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("f_Id").DataType = typeof(Int32);
            dt.Columns[0].DataType = typeof(Int32);
            dt.Columns.Add("f_Desc");
            dt.Columns[1].DataType = typeof(string);
    
    
            for (int i = 0; i < values.Count; i++)
            {
                dt.Rows.Add(i, values[i]);
            }
    
            col.DataSource = dt;
            col.DisplayMember = dt.Columns[1].ColumnName;
            col.ValueMember = dt.Columns[0].ColumnName;
        }
    }
    

    and here is the usage:

    List<string> lControlType = new List<string>();
    lControlType.Add("Semplice");
    lControlType.Add("Esteso");
    HGrid.MakeComboBoxColumn(ref pControlType, lControlType);
    

    I hope that will be useful for everyone!

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

Sidebar

Related Questions

I have hit upon this problem about whether to use bignums in my language
I have a problem with my datagridview that is binding to an access table(access
I have a winForms DataGridView bound to a List<MyObjectType> . My problem is that
Software I use: C#, VS-2005. I have a populated combobox in datagridview. I have
So I have this datagridview that is linked to a Binding source that is
I have a DataGridView that I'm populating from a list. The function that edits
I have this problem I'm hoping someone knows the answer to. I have an
everybody; I have this problem in asp.net, I have a page where I insert
I have seen this problem arise in many different circumstances and would like to
I have faced this problem quite often during the last couple of months, during

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.