1 Dictionary<string, string>test = new Dictionary<string, string>();
2 test.Add("1", "第一行");
3 test.Add("2", "第二行");
4 test.Add("3", "第三行");
5 comboBox1.DataSource = new BindingSource(test, null);
6 comboBox1.DisplayMember = "Value";
7 comboBox1.ValueMember = "Key";
8
9
10 string value = ((KeyValuePair<string, string>)comboBox1.SelectedItem).Value;
记性不好,方便检索
时间: 2024-09-30 09:35:09