我们的字典是这样的:如何获得的SelectedValue的价值组合框充满字典
var dictionary = new Dictionary<int, int> { { 0, 100 }, { 1, 202 }, { 2, 309 }, };
等很多价值观。字典绑定到组合框是这样的:
comboBox1.ItemsSource = dictionary;
comboBox1.DisplayMemberPath = "Value";
我不知道如何可以得到这个组合框的SelectedValue,如果comboBox.Text仅适用于手动输入值,并验证码:
string value = comboBox1.SelectedValue.ToString();
返回值像[1,202],而我需要明确的int TValue“202”。我无法找到类似的问题,所以我在那里问它,并希望答案可能对其他人有用。
使用此替代方法学习如何使用“字典或字典”创建'BindingSource'' http://stackoverflow.com/questions/6412739/binding-combobox-using-dictionary-as-the- datasource –
MethodMan
2013-03-22 21:16:23