How to bind enum with ComboBox Control in C#

Waqas Anwar
07 September 2009
5372 Views

You have created an enum in C# and you want to bind the enum with the data bound controls such as ComboBox control. You can use GetValues() method of Enum class for this purpose as shown below:

public enum WeekDays
{
   Mon, Tue, Wed, Thu, Fri, Sat, Sun
}

To bind the above enum with ComboBox control use the following:
comboBox1.DataSource = Enum.GetValues(typeof(WeekDays));