Tuesday, 15 January 2013

vb.net - Find a selected item in a ListBox -


Background: I have a list box that allows multiple selections. My list box has a specific value, if selected, it requires a different code path to run and all other selections are from another path.

Problem: I can not understand how to write it correctly in VB.NET, to the way I think it is to work for it.

code:

  listbox1.SelectedItems in the string for each item if listbox1.SelectedItem = MyValueIf this happens then it ends then the next   

If I make multiple selections in my list, the code does not work correctly, it only works correctly if myValue Listbox is the only selection in Box 1.

Any suggestions?

Your recurrence is incorrect, you should use item values ​​in your loop: < Pre> 1 in the string in listbox for each item. If the item chosen = myValue then what to do or what to do next if the next

basically does the following for each loop: (Please excuse any syntax errors, mine VB will rust)

  Index to integer = 0 to listbox 1 Selected items Lang Diff items = List box 1. Selected items [index] next    

No comments:

Post a Comment