I\'m working on a GUI that allows the user to manipulate xml files. I display the xml file in a datagridview organized neatly by columns through xml elements. I allow the us
If we have bound a datagridcomboboxcell
with a different DisplayMember
and ValueMember
, like so:
dgcombocell.DisplayMember = "Name";
dgcombocell.ValueMember = "Id";
dgcombocell.DataSource = dataset1.Tables[0];
Then for getting SelectedText
, and SelectedValue
, we can write this code:
string SelectedText = Convert.ToString((DataGridView1.Rows[0].Cells["dgcombocell"] as DataGridViewComboBoxCell).FormattedValue.ToString());
int SelectedVal = Convert.ToInt32(DataGridView1.Rows[0].Cells["dgcombocell"].Value);
I hope it solves your problem.