我有幾個不同的字典結構,我想要顯示在組合框中。根據組合框中的鍵顯示字典成員
在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";
}
我怎麼會去根據選擇鍵選擇相應的值?
在此先感謝。
列表值= jumpCombination [關鍵] –
jdweng