问题
How do you count the amount of values in a list box that are selected, rather than all of those within the list box?
I need to get the number and then make it a string. Once i have the number i can change this easily to a string
thanks
回答1:
yourlistbox.SelectedItems.Count
回答2:
I have done this using ListBox1.GetSelectedIndices.Length
回答3:
You can loop through the items in the listbox like so:
For Each item As ListItem In MyListBox.Items
If item.Selected Then
'Do something
End If
Next
来源:https://stackoverflow.com/questions/10014493/counting-selected-items-in-a-list-box