Ok, this is hard to explain, I will try my best to be clear:
I have several hundred "string" items where each one may take you to one of 13 different forms. Instead of doing something like:
if (string == string) goto form1
hundreds of times I was hoping to do something like the following:
The user could care less which form comes up and does not need to know, they just click on the string object and it takes them to the correct form.
I think it would be easy if each string object had an associated INT value and then I go to the appropriate form instead of doing all of the string processing and comparison.
I do not see a way to do this with listbox. Is there a different structure I should use, or a work around to make this work with listbox?
Thanks for any help.
EDIT: So, I decided to use a dataset for this instead of a class object:
DataRow row;
row = itemTableA.NewRow();
row["itemA"] = "Item Description";
row["formA"] = 1;
itemTableA.Rows.Add(row);
row = itemTableA.NewRow();
row["itemA"] = "Item Description";
row["formA"] = 2;
itemTableA.Rows.Add(row);
For every data object (maybe I will try to read in from a file if I can figure it out)
Then for my listbox I do:
itemList.DataSource = itemTableA;
itemList.DisplayMember = "itemA";
itemList.ValueMember = "formA";
Lastly, I do my if statements:
if (itemList.SelectedValue.ToString() == "1")
do something;
if (itemList.SelectedValue.ToString() == "2")
do something;
etc.