473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DataGridView Combobox column Error

I've populated all the cells in a combo box column with values from 1 -
50 using the following code:

foreach (DataGridViewRow row in uxTabSummary.Rows)
{
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)
row.Cells["numRows"];
for (int i = 1; i < 51; i++)
{
cell.Items.Add(i);
}
}

However, after the user changes a value in the drop down combo box, and
moves the focus to another cell, a "System.ArgumentException:
DataGridViewComboBoxCell value is not valid".

Googling shows an extensive number of people suffering the same, but
I'm none the wiser.

Is there a simple solution to this?

Greg.

Jul 26 '06 #1
2 9630

Greg wrote:
I've populated all the cells in a combo box column with values from 1 -
50 using the following code:

foreach (DataGridViewRow row in uxTabSummary.Rows)
{
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)
row.Cells["numRows"];
for (int i = 1; i < 51; i++)
{
cell.Items.Add(i);
}
}

However, after the user changes a value in the drop down combo box, and
moves the focus to another cell, a "System.ArgumentException:
DataGridViewComboBoxCell value is not valid".

Googling shows an extensive number of people suffering the same, but
I'm none the wiser.

Is there a simple solution to this?

Greg.
Perhaps you can try adding a DataTable to hold all those values for the
ComboBox, then setting the ComboBoxColumn.DataSource to the DataTable.
The ComboBoxColumn.ValueMember's data must be valid for the underlying
column in the DataGridView.

B.

Jul 26 '06 #2
Great, thanks!

Brian Tkatch wrote:
Greg wrote:
I've populated all the cells in a combo box column with values from 1 -
50 using the following code:

foreach (DataGridViewRow row in uxTabSummary.Rows)
{
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)
row.Cells["numRows"];
for (int i = 1; i < 51; i++)
{
cell.Items.Add(i);
}
}

However, after the user changes a value in the drop down combo box, and
moves the focus to another cell, a "System.ArgumentException:
DataGridViewComboBoxCell value is not valid".

Googling shows an extensive number of people suffering the same, but
I'm none the wiser.

Is there a simple solution to this?

Greg.

Perhaps you can try adding a DataTable to hold all those values for the
ComboBox, then setting the ComboBoxColumn.DataSource to the DataTable.
The ComboBoxColumn.ValueMember's data must be valid for the underlying
column in the DataGridView.

B.
Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Aaron Smith | last post by:
Ok, this is an odd one, but I could use some assistance with the framework 2 in VB.Net... I want to have a DataGridViewColumn, only have it use the ComboBox, then when they drop down the...
3
by: Bob | last post by:
Thinking two things, 1- Creating a userControl -yeah you guessed it, a multi column drop down combobox - I've looked at several articles and did not find what I need, one that's bindable and that...
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
8
by: Brian Pelton | last post by:
This is on .Net 2.0 in a WinForms application. I have a DataGridView that is bound to a BindingSource. The DataGridView has 3 columns. The first two are "normal" text columns and the last is a...
4
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I am trying to populate a DataGridView Combobox column with a different data binding source (dataset) depending upon a selection made in a previous column. I can handle the previous column but how...
3
by: =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post by:
New to databinding in vs2005, I always did it manually in 2003. I have no problem loading comboboxes, and a change in that combobox changes the data in the textboxes but I can not figure out a way...
0
by: sixths3ns3 | last post by:
My DataGridView has two columns. Combobox Column 2 displays list based on Combobox Column 1 selected value. The code below works fine when I select a value on Column 1, and select a value on Column...
18
by: Andrus | last post by:
Marc, Thank you very much. I have issue on implementing add row properly using this. User presses down arrow in last row in grid starting adding new row. Then user changes its mind desiding...
9
by: Miro | last post by:
My current headache is proper is with the datagridview I am starting to realize that a DataGridView within vs2008 is not as 'robust' as a 'textboxfield' by default for example. Example: A...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.