ComboBox 动态绑定数据

 Dictionary<string, int> dic = new Dictionary<string, int>();

            dic.Add("现金", 0);
            dic.Add("银行卡", 1);
            dic.Add("信用卡", 2);
            dic.Add("股票", 3);
            dic.Add("基金", 4);
            dic.Add("其他", 5);

            BindingSource bs = new BindingSource();
            bs.DataSource = dic;

            comboBox1.ValueMember = "value";
            comboBox1.DisplayMember = "key";
            comboBox1.DataSource = bs;

            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

获取选中的值:
 MessageBox.Show(comboBox1.SelectedValue.ToString());

你可能感兴趣的:(combobox,动态绑定数据)