I needed to know if one can set the ValueMember property of a DataGridViewComboBoxColumn directly from a list of strings.
e.g.
List<string> productNames = new List<string>();
List<Products.Product> t = new List<Products.Product>();
foreach (var p in products)
{
var x = p.Product;
itemListing = x;
foreach (var pn in x)
{
productNames.Add(pn.name);
}
}
.............
// set values to combobox column cells in datagridview
GridSellProducts.Rows.Add();
DataGridViewComboBoxColumn cmbItems = (DataGridViewComboBoxColumn)GridSellProducts.Columns["Item"];
cmbItems.DataSource = productNames;
cmbItems.DisplayMember = cmbItems.ValueMember;
cmbItems.ValueMember = // code to put here
cmbItems.AutoComplete = true;
Didn't quite get the example in http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.datasource.aspx
How does one set cmbItems.ValueMember
?