shows how to select items in a ListBox in code

Started by nandagopal, May 20, 2009, 07:10 PM

Previous topic - Next topic

nandagopal

For a ListBox that allows single selection, either set the SelectedIndex or the SelectedItem property.

For a ListBox that allows multiple selection, use the SetSelected method to selected or deselect items.


' Select item 4 in ListBox1.
' (Alternatively set ListBox1.SelectedItem.)
ListBox1.SelectedIndex = 4
'Or do this: ListBox1.SelectedItem = ListBox1.Items(4)

' Select every third item in ListBox2.
For i As Integer = 1 To ListBox2.Items.Count - 1 Step 3
    ListBox2.SetSelected(i, True)
Next i



dhoni

this code is very useful to me for select item in listbox code
it can easily use in vb.net code

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview