Load values of enum type into a combobox

combobox, enums, vb.net

Solution

You can use `Enum.GetValues` to get a list of values for an enum then iterate the result:

For Each i In  [Enum].GetValues(GetType(EnumExample))
  combo.Items.Add(i)
Next

Or, as mentioned by @Styxxy:

combo.Items.AddRange([Enum].GetValues(GetType(EnumExample)))

Problem

Given the following enum: ``` Enum enumExample world oblivion holiday End Enum ``` I can add its values to a list of ComboBox items like this: ``` combo.Items.Add(enumExample.holiday) combo.Items.Add(enumExample.oblivion) combo.Items.Add(enumExample.world) ``` Is there a shorter way?

Original source