vb.net - VB Check if Multiselect in Listbox -
simple thing: how can check if user has selected more 1 item in listbox? tried this:
if listbox.selecteditems(1) ...
but returned out of range exception...
thx help
the code have attempting access second item in selecteditems
collection, holds of selected items in listbox
. because default property of selecteditems
item
, accepts zero-based index of item parameter. getting "out of range exception" because there less 2 items selected, means there no value return @ index = 1.
instead, check if user has selected more 1 item, need use count
property of selecteditems
collection. example:
if listbox.selecteditems.count > 1 ''#your code here end if
Comments
Post a Comment