|
-
Nov 10th, 2016, 02:12 PM
#1
Thread Starter
Lively Member
Acquiring the index number in a listbox
Hi. I have a listbox (LBProd) that is populated at form load from a text file using:
Dim Prods() As String = IO.File.ReadAllLines("E:\Rajja\TxtFiles\Product1.txt")
LBProd.Items.AddRange(Prods)
It's an extensive list! There is a Textbox into which the user can start to type the name of a product and it will highlight the product in the listbox.
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles tb1.TextChanged
Dim i As Integer = LBProd.FindString(tb1.Text)
LBProd.SelectedIndex = i
If tb1.Text = "" Then
LBProd.SelectedIndex = -1
End If
End Sub
The user can then select the product in the listbox from the list of matches; but, having selected the product I need to retrieve the index of that selection in the list to use in the next stage of the program, but I'm struggling to get the index when the user clicks the selection in the listbox.
Would be grateful for any suggestions and thanks in advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|