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 on
use c# dictionary for this,
Dictionary<string, string> list = new Dictionary<string, string>();
list.Add("item 1", "Item 1");
list.Add("item 2", "Item 2");
list.Add("item 3", "Item 3");
list.Add("item 4", "Item 4");
dropdown.DataSource = list;
dropdown.DataTextField = "Value";
dropdown.DataValueField = "Key";
dropdown.DataBind();
EDIT:
listBox.DataSource = new BindingSource(list, null);
listBox.ValueMember = "Key";
listBox.DisplayMember = "Value";