Suppose I have a fixed set of identifiers organized in, for example, a dictionary.
public static Dictionary<int, string> clientIds = new Dictionary<int, string>()
{
{ 0, "aa" },
{ 1, "ab" },
{ 2, "ac" },
{ 3, "ba" },
{ 4, "bb" }
};
Then, I dynamically, at runtime, add to a ComboBox
"friendly names" that are related to those identifiers (I don't know, however, which ones will be added.
clientIdCombo.Add(friendlyName);
Suppose that, at index zero, the friendly name "Alpha Beta" is added. That would relate to "ab" identifier. How can I know the user has selected the "ab" identifier, without having to condition based off the text displayed on the combo to the user? I tried using a BindingList
instead, but that only provides me with that displayed text as well.
It sounds like something simple - how can I add underlying data to each ComboBox
index? The simplest possible approach would be preferable, though multiple solutions are welcome.
Thanks.