How do I get at the listbox item's “key” in c# winforms app?

前端 未结 6 995
南旧
南旧 2020-12-20 20:49

I am writing a winforms app in which a user selects an item from a listbox and edits some data that forms part of an associated object. The edits are then applied from the o

6条回答
  •  执念已碎
    2020-12-20 21:07

    I know this is a very old post, but I was unable to cast my list box items into a Dictionary item. This solution worked for me in .NET 3.5 for windows forms.

    KeyValuePair kvp = (KeyValuePair)listBoxSystems.SelectedItem;
    string szValue = kvp.Value;
    

提交回复
热议问题