• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1190
  • Last Modified:

DatagridView ComboBox Column As Integer

Hello
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
0
doddwell
Asked:
doddwell
  • 2
1 Solution
 
Bob LearnedCommented:
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...
0
 
doddwellAuthor Commented:
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?

Thanks.
0
 
Bob LearnedCommented:
Example:

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

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now