【发布时间】:2017-02-10 10:43:32
【问题描述】:
我想在组合框中显示几个不同的字典结构。
在 JumpType.cs 中:
public SortedDictionary<int, List<string>> jumpCombination = new SortedDictionary<int, List<string>>();
字典结构如下所示:
Key Values
1 Flygande
EjFlygande
2 Bak
Pik
Test
3 ...
我在我的 UI 中创建了两个组合框,如下所示:
Select Key: _____________
| ComboBox |
-------------- __________
_____________ | OK |
Select Value: | ComboBox | ----------
--------------
在 Form1.cs 中
InitializeComponent();
JumpType jt = new JumpType();
jt.addjumpCombination(); // populating the dictionary
if (jt.jumpCombination != null)
{
comboBoxJumpComboKey.DataSource = new BindingSource(jt.jumpCombination, null); // Key => null
comboBoxJumpComboKey.DisplayMember = "Value";
comboBoxJumpComboKey.ValueMember = "Key";
comboBoxJumpComboValue.DisplayMember = "Value";
}
我将如何根据所选键选择相应的值?
提前致谢。
【问题讨论】:
-
列表
values = jumpCombination[key]
标签: c# .net dictionary combobox