Iterating over an enum

Is there a way of iterating over all possible values of an enum?

What I want to have is that all possible choices of a combobox corrrespond to an enum. I use a DataTable as the DataSource of the ComboBox, with two columns, one column has the type string and is set as the DisplayMember, the other has the type of the enum and is the ValueMember.

I want to build the table automatically somehow "iterating over the enum" and pulling the display string for each value from a configuration file.

Thanks,

Hans

[553 byte] By [hmrupp] at [2007-12-18]
# 1

foreach (HorizontalAlignment a in Enum.GetValues(typeof(HorizontalAlignment)))

{

Console.WriteLine(a);

}

DanielRieck at 2007-9-8 > top of Msdn Tech,Visual C#,Visual C# Language...