Answer: Create an enum and using Reflection, bind the enum contents with the DataSource
property of ComBoBox
ex:
enum WeekDays
{
Sunday,
Monday,
Tuesday
}
Write this statement in Form_Load event handler
combobox1.DataSource=Enum.GetValues(typeof(WeekDays));
. GetValues is a static method of Enum class and
retrieves an array of the values of the constants in a specified enumeration.//
. It expects the enum name as the parameter and the typeof operator retreives the
. contents of the user-defined enum
|
Alert Moderator