Member Avatar for cool_intentions

Hello,
I’m trying to bind Dictionary<string, object> parameters with my combo box, but I don’t know how to do that.

This is my code:

Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("option1",parameters);
            parameters.Add("option2", parameters);
            parameters.Add("Option3", parameters);

I would like to get option1, option2 and option3 in combobox on my Windows Form Applikation

Thanks for your help.

comboBox1.DataSource = new BindingSource(parameters, null);
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";
Member Avatar for cool_intentions
comboBox1.DataSource = new BindingSource(parameters, null);
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";

Thanks very much, it works.

Big Thanks for your help.:)

        var colors = new Dictionary < string, object > ();

        comboBox1.DataSource = new BindingSource(colors, null);
        comboBox1.DisplayMember = "Value";
        comboBox1.ValueMember = "Key"; 

Source:...Bind Dictionary to Combobox

Jeryy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.