I\'m having some trouble trying to get the ValueMember value I\'ve set. I\'m trying to use a combobox to select a windows forms report. I can get the Name but not RptValue.
You should use the DataSource property. Try this:
BindingList<Data> _comboItems = new BindingList<Data>();
_comboItems.Add(new Data { Name = "Select", RptValue = "Select" });
_comboItems.Add(new Data { Name = "All Food Values", RptValue = "AllFoodValues.rdlc" });
...
comboBox1.DataSource = _comboItems;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "RptValue";
And then access the selected value:
strReport = "ReportViewer." + comboBox1.SelectedValue;
String s;
s=comboBox1.SelectedValue.tostring()
This worked for me:
combobox.valuemember="id"
combobox.displaymember="name"
combobox.datasource=dt