【发布时间】:2012-09-17 23:11:43
【问题描述】:
我以这种方式使用基础值和显示值填充我的组合框:
Dictionary<int, string> Platypi = duckBillData.GetPlatypiVals();
comboBoxPlatypus.DataSource = new BindingSource(Platypi, null);
comboBoxPlatypus.ValueMember = "Key";
comboBoxPlatypus.DisplayMember = "Value";
现在我想提取所选项目的 ValueMember。我怎么做?没有一个“明显”的东西似乎有一个“ValueMember”......我试过了:
int id = comboBoxPlatypus.ValueMember;
int id = comboBoxPlatypus.SelectedIndex. <-- no "ValueMember" here...
int id = comboBoxPlatypus.SelectedItem. <-- no "ValueMember" here...
【问题讨论】:
标签: c# winforms dictionary combobox key-value-observing