How can I get the name of a certain item in a listbox;
lets say that we have a for loop
for(int i=0; i< this.tr_lst.Items.Count;i++) \\ i is the index
then i want to make a switch statement
switch (the name of the item which has the index i)
How can I get the name of a certain item in a listbox;
lets say that we have a for loop
for(int i=0; i< this.tr_lst.Items.Count;i++) \\ i is the index
then i want to make a switch statement
switch (the name of the item which has the index i)
I like a foreach loop for this sort of thing:
foreach (ListItem item in tr_list.Items) {
string name = item.Text;
...
}
unless you really need access to the index. If so, then I think
string name = tr_list.Items[i].Text
would do it.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.