I have a combobox with values like members, payments, visits like….
we can do like this
if(combobox.text = "members")
{
\\do something...
}
if(combobox.text = "visits")
{
\\do something...
}
if(combobox.text = "payments")
{
\\do something...
}
we can do like this but i dont want to hardcode like this
is there any other way to use combo box values with their id’s not using text like the above mentioned
can any one help on this ….
the alternative is to fill the combo box with items which have value and text and these could be, for example, two columns of a table in the database.
In this way in the loading of the items there is no hard coded data and you can load more items (or simply different ones) by editing the data in that database table.
if the number of items is very limited you can also create an enum and use the enum values to verify what is the currently selected value, with some modifications of the code you have shown above.