Hi,
I am providing itemssource of a combobox to be a NameValueCollection.
But I am not able to see any thing in combo when I set the property:
cmb.DisplayMemberPath="Value";
I want the values of NameValueCollection to be displayed in combo.
How can i do this.!!!
Please help.
Thanks,
Priyanka
Databind NameValueCollection to combo to display values of collection
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 10, 2010, 11:23 PM EST
Here is the code for simple binding a ComboBox with a DataView or Datasource:
// Combobox Databinding
cbCust.DataSource = dsView;
cbCust.DisplayMember = "Customers.CompanyName";
cbCust.ValueMember = "Customers.CustomerID";
If you want to bind your ComboBox with a CustomDataClass then here is the code lines:
ComboBox1.Databindings.Clear
ComboBox1.Databindings.Add ("SelectedItem", objDataClass,
Hope it helps you.
Please mark as answer if your problem get solved.
Priyanka22 reputationPosted Mar 13, 2010, 4:08 AM EST
This all works well with other collections,
but I am not able to get the values get displayes in combobox if binded to a NAMEVALUECOLLECTION specifically, if I provide a DisplayMemeberPath.