I'm writing a C# app using a ListBox in WinForms.
I get my data (id and full name) from an XML file. I want to show full names in the listbox and when I select one of them, I want to get the relevant id.
I tried using SelectedValue
property with no luck.
I also tried KeyValuePair
and it shows "[full name, id]" in the listbox, which is not what I wanted:
LB_UserList.Items.Add(new KeyValuePair<string, string>(full_name, node["user_id"].InnerText));
How can I simulate a HTML select in C# in short? I want to show full names in the listbox and to get relevant id in the backend.