DatagridView ComboBox Column As Integer

Posted on 2011-05-01
Last Modified: 2012-05-11
I have a bound DataGridView with an integer column called TenantShare.  I can add data to it without any problmes if I leave the column as a textbox.  I want the column to be a combobox so I changed the ColumnType property to DataGridViewComboBoxColumn and gave the combobox sme values (0, 50, 100).

When I run the form and try to add data, I get an error saying Value Not Valid.  I think this is because the items I added to the combobox are being stored as strings - but I don't know how to add them as Integers

Thanks, Simon
Question by:doddwell
    LVL 96

    Expert Comment

    by:Bob Learned
    How do you bind the values to the DataGridViewComboBoxColumn?  You should be able to bind to a list of integers, but I am not sure that it will help you with the other parts of the DataGridView...

    Author Comment

    To bind values you do this (Visiual Studio 2010):

    Click on DataGridViewTasks
    Edit Columns
    Choose the column you want and chnage the ColumnType to ComboBox

    How can I bind a list of integers?

    LVL 96

    Accepted Solution


    List<int> numberList = new List<int>() {0, 50, 100}; 
    this.NumberComboBoxColumn.DataSource = numberList;

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now