Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridViewComboBoxCell SelectedValue

$
0
0

I have a DataGridViewComboBoxColumn and a DataGridViewComboBoxCell template with a DataSource, DisplayMember and ValueMember assigned. How can I read the value of the ValueMember property when a user selects an item in a corresponding DataGridViewComboBoxCell?  The ComboBox class has the SelectedValue property.  What would be the similar property for DataGridViewComboBoxCell or DataGridViewComboBoxColumn?

...

cell.DataSource = ListBoxItems;
cell.DisplayMember = "fieldLabel";
cell.ValueMember = "ID";
dgvComboBoxColumn.CellTemplate = cell;

...

// The next line returns the displayed value of the cell
string sVal = dgvSandbox.Rows[i].Cells[j].Value.ToString();

// How can I get the ValueMember value?
...


Rob E.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>