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
Okay so the answer came as a result of Andy's answer, hence my upvoting that answer.
But when I created a little class and tried to cast the listitem into that class the program threw an exception.
Revealingly the exception told me that the program could not cast a DictionaryEntry into a class of the type I had defined.
So I deleted the proxy class and reframed the request thus:
DictionaryEntry de = (DictionaryEntry)listbox.SelectedItem;
string htKey = de.Key.ToString();
And it's all good.
Bizarrely simple answer in the end. Thanks for the hint Andy.