jM2*_*.me 2 c# listbox selecteditem bindinglist key-value
ListBox 对象绑定 BindingList<KeyValuePair<string, string>>
在SelectionChanged事件中,我需要将所选项目作为 KeyValuePair<string, string>
以下代码给出错误,因为KeyValuePair不能用作引用类型.
KeyValuePair<string, string> selectedProperty = listProperties.SelectedItem as KeyValuePair<string, string>;
Run Code Online (Sandbox Code Playgroud)
什么是好的解决方法?
尝试使用直接转换而不是as:
var selectedProperty = (KeyValuePair<string, string>)listProperties.SelectedItem;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4019 次 |
| 最近记录: |