counting selected items in a list box

核能气质少年 提交于 2019-12-12 02:56:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!