I suggest you create a class:
public class Permission { public Int32 Index { get; set; } public String Value { get; set; } }
And fill in the ComboBox as follows:
List<Permission> permissions = new List<Permission>() { new Permission(){ Index = 1, Value ="Access" }, new Permission(){ Index = 2, Value ="Create" }, new Permission(){ Index = 3, Value ="Delete" }, new Permission(){ Index = 4, Value ="Modify" }, new Permission(){ Index = 5, Value ="All" }, }; comboBoxFilter.DisplayMember = "Value"; comboBoxFilter.DataSource = permissions;
Using the code above, you can access the integer value using the following code:
(comboBoxFilter.SelectedItem as Permission).Index
source share