I am filling a combobox with dropdown values of type WagonType. The function I am calling returns a dictionary where the key is the WagonTypeID and the value is the WagonType.
RepositoryItemComboBox comboWagonTypes;
Dictionary<int, WagonType> GetAllWagonTypes()
{
...
}
If I use AddRange to fill the collection will it insert only the values or both the keys and the values?
comboWagonTypes.Items.AddRange(GetAllWagonTypes());
Or do I need to iterate through the dictionary and insert the values myself?
foreach (var wagonType in GetAllWagonTypes())
comboWagonTypes.Items.Add(wagonType.Value)
You need to use the Values property of the dictionary.
Just do