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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

c# - How to execute a particular part of code asynchronously in a class -

c# - Asterisk click to call -