Let’s say I have this items:
comboBox.Items.Add("Access"); // make it equal to 31
comboBox.Items.Add("Create"); // make it equal to 34
comboBox.Items.Add("Delete"); // make it equal to 36
comboBox.Items.Add("Modify"); // make it equal to 38
Now, I call
comboBox.SelectedIndex = 34; // want to "Create" item has been chosen
What is the easiest way to do that ?
It depends a lot on how your data is going to be managed.
If your items are not going to be modified over the course of your program you can simply use a dictionary as a mapping table.
Then simply use the following:
You can even put this logic in a class that inherits from ComboBox for better abstraction.