c# combox与hashtable_arraylist填充数据源与下拉列表框示例

private void Form1_Load(object sender, EventArgs e)
        {
            ArrayList al = new ArrayList(3);
            al.AddRange(new string[] { "存款","贷款","外汇"});
            comboBox1.DataSource = al;


            ArrayList a2 = new ArrayList(2);
            Hashtable ht = new Hashtable();
            ht.Add("1","翟勋杨");
            ht.Add("2","翟勋章");
            foreach (DictionaryEntry entry in ht) //键值对通过dictionaryentry把hashtable
            //添加到arraylist
            
                a2.Add(entry);
            comboBox2.DataSource = a2;
            label1.Text = comboBox2.Items.Count.ToString();
            comboBox2.ValueMember = "Key";
            comboBox2.DisplayMember = "Value";
          
        }
请使用浏览器的分享功能分享到微信等