// Code in C# Add | Fill ComboBox with Enum values
//Declair Enum
public enum UserLevel { Admin = 0, Client = 1, Other = 2, Agent = 3, Supplier = 4, Accounts = 5, CheckPost = 6, Manager = 7 };
//Filling combobox with Enun Values
cmbUserLevel.DataSource = Enum.GetValues(typeof(classEnum.UserLevel));
//Set initial Value
cmbUserType.SelectedItem = classEnum.UserLevel.Other;
//Getting Selected Values
classEnum.UserTypeAtGoodsRecpt usr = (classEnum.UserTypeAtGoodsRecpt)Enum.Parse(typeof(classEnum.UserTypeAtGoodsRecpt), cmbUserType.SelectedItem.ToString());
// To get the value
int userVal=(int)usr;
No comments:
Post a Comment