Selected item index on a listbox...
Hi every1 !
I have a listbox and an array.
I want to link every listbox item to an array value, so, when I double click an item I want to retrieve its Index ( 1,2,3.....) like on VB6... but
listbox.selecteditem returns the string, not the position...
I cant find a command lie .item.index....
help ?
Thanks !!
Re: Selected item index on a listbox...
Is this what you want ?
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arry() As String = {"item1", "item2", "item3"}
'bind the array to the listbox
ListBox1.Items.AddRange(arry)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
'show the index of selected item
MessageBox.Show(ListBox1.SelectedIndex)
End Sub
End Class