I am using a
datagridview,
in that i am using a
datagridviewcomboboxcolumn.
There are three rows in this datagridview so that there are three combobox created in each of these rows in datagridviewcomboboxcolumn.
These comboxes have same items but the selected index of each item is different. For example : suppose there are three items A,B and C. First combobox box selected item is A,second have B and third have C, so selected index is 0,1 and 2 respectively.
Now , I am doing this,
DataTable dt_Groupingdetails;
//Grouping details have changed values Z,B,C for that column(comboboxcolumn).
List<string> list_groups = new List<string>();
this.gView_cBoxgroup.DataSource = className.GetChangedValues();
public static List<string> GetChangedValues()
{
foreach (DataRow drow in dt_Groupingdetails.Rows)
list_groups.Add(drow["comboboxcolumn"].ToString());
return list_groups;
}
When i am changing the DataSource , Each combobox's selected index also changed to 0. But i don't want to change the index . I want to Update only the index item for each row.
How can i do this?
A workaround will be to keep the selected index in a temp variable before changing the
DataSource
and then setting back the selected index of the ComboBox Column with the temp variable, after the DataSource changed.