1 Replies - 5441 Views - Last Post: 02 April 2011 - 06:07 AM Rate Topic: -----

#1 Servatis  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 394
  • Joined: 30-March 09

DataGridView ComboBox items [SOLVED]

Posted 01 April 2011 - 01:09 PM

I have a DataGridView.
on this I have a DataGridViewComboBoxColumn called Rider.
I have a List<string> called riderList.
the datasource of Rider = riderList

Rider.DataSource = riderList;


now what I want to do is be able to add an item to the riderList and then be able to use the new item in my column.

I'm using the following code right now. to add the item to the combobox column

riderList.Add("*" + riderDGV[1, e.RowIndex].Value.ToString());
Rider.DataSource = riderList;


the problem is when i look at the list in the column it shows up fine. but when i select the newly added item I get a message that the value is incorrect. and the result is that the cell resets to the first item in the combobox and then just breaks. when ever i hover over the cell that gave the error i get the same error.

this is the error

Quote

---------------------------
DataGridView Default Error Dialog
---------------------------
The following exception occurred in the DataGridView:



System.ArgumentException: DataGridViewComboBoxCell value is not valid.



To replace this default dialog please handle the DataError event.
---------------------------
OK
---------------------------


Is it impossible to add items to these comboboxes on the fly? or am I just doing this wrong?

This post has been edited by Servatis: 02 April 2011 - 06:08 AM


Is This A Good Question/Topic? 0
  • +

Replies To: DataGridView ComboBox items [SOLVED]

#2 Servatis  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 394
  • Joined: 30-March 09

Re: DataGridView ComboBox items [SOLVED]

Posted 02 April 2011 - 06:07 AM

Ok so apparently I'm not allowed to have the List as the datasource. the column doesn't like it.

So now I just have them run side by side. adding to both the Rider.Items and riderList. and not having riderList as the datasource of Rider.

This appears to work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1