C#: Populate a ComboBox with Enum Values

A C# example for populating a ComboBox with the values of an Enum.

The Enum:

public enum FromAccount
    { checking = 0, savings = 1, foodstamps = 2, cashbenefit = 3 }

The Code:

comboBox1.DataSource = Enum.GetValues(typeof(FromAccount));
comboBox1.SelectedIndex = 0;



   

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading