PC Review


Reply
Thread Tools Rate Thread

DataGridView Combobox column Error

 
 
Greg
Guest
Posts: n/a
 
      26th Jul 2006
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.

 
Reply With Quote
 
 
 
 
Brian Tkatch
Guest
Posts: n/a
 
      26th Jul 2006

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.

 
Reply With Quote
 
Greg
Guest
Posts: n/a
 
      28th Jul 2006
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox column in dataGridView =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= Microsoft C# .NET 1 11th Apr 2007 11:14 AM
DataGridView ComboBox Column on the fly Terry Olsen Microsoft VB .NET 1 20th Dec 2006 04:51 AM
DataGridView Combobox column Error Greg Microsoft Dot NET Framework 2 28th Jul 2006 09:51 AM
DataGridview combobox column =?Utf-8?B?amlsbA==?= Microsoft Dot NET Framework Forms 1 4th Feb 2006 08:33 PM
DataGridView with a ComboBox column error (listing objects) gsa Microsoft Dot NET Framework Forms 3 21st Jan 2006 03:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:46 AM.