2
Answers

Populating a Combobox from a Dictionary

John Doe

John Doe

14y
12.8k
1
Hey, I am trying to get my Combo box to populate itself with stuff from a dictionary I created in another class.  I tried to link it with the DataSource property but its empty.  Any ideas how to do this?  Thanks in advance
Answers (2)
1
Mike Gold
NA 32k 21.3m 14y

Dictionary<int, string> myDictionary;

// populate dictionary

cmbDate.DataSource = New BindingSource(myDictionary, null)

cmbDate.DisplayMember = "Value"

cmbDate.ValueMember = "Key"

0
Sam Hobbs
NA 28.7k 1.3m 14y
If there is no data in the DataSource then of course there will be no data in the ComboBox.