0

I have many List:

List<int> list1 = new List<int>(){ 1, 2, 3};
List<int> list2 = new List<int>(){ 1, 2};
List<int> list3 = new List<int>(){ 1, 2, 3, 4};

And I have this code:

foreach (Subtipo STC in lista.Subtipos)
{
  dataGridViewTiposConsulta.Rows[index].Cells[6] as DataGridViewComboBoxCell).DataSource = STC.active ? list1 : list2;
}

When i execute the program, it work fine. But when a change de selected item in combobox cell the value that is show is always the first in the list of datasource.

Why? Thanks

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
Sponsor
  • 368
  • 4
  • 9
  • If the DataGridView is bound to a datasource then all the ComboBoxes in the same column must have the same datasource (and maybe even if the grid is not bound, I'm not sure without testing). There are things you can do to filter the combobox datasource to make it appear to have different data between rows, but they must all have the same base data binding. – Crowcoder Mar 24 '15 at 16:20
  • I use diferentes List to combobox datasource. The problem not be here, but in when i select one item into combobox, and the combobox don´t display the item that i has selected. – Sponsor Mar 25 '15 at 17:36

0 Answers0