I was recently attempting to bind a combo box to something other than a database data source. I found this snippet of code very useful for binding it to a dictionary of items. This allows more flexibility than just editing the item list, since it allows a different display and value member to be set.
Note: This method does not seem to work with a sorted dictionary.
        Dim ComboBoxSourceDictionary As New Dictionary(Of String, String)
        'add all your items here
        ComboBoxSourceDictionary.Add("aKey", "aValue")
        ComboBox1.DataSource = New _ 
                    Windows.Forms.BindingSource(ComboBoxSourceDictionary, Nothing)
        ComboBox1.DisplayMember = "Value"
        ComboBox1.ValueMember = "Key"

9/30/2012 07:09:44 pm

I thank you for sharing this very nice information. I always want and love reading quality contents. Keep sharing. Best wishes for your further efforts.

9/4/2014 07:54:42 am

This article is very informative. Though we learn everyday something, this is the first time I see a categorization of learning. It is very useful. I will use it in my life and share it with others. Thanks a lot.


Leave a Reply.