Trying to find a better way to search a listview using a textbox.
The code currently finds the correct row/value. The problem is that once the an item/row is selected and the down (or up) arrow is pushed the listview does not
select the next item. Instead, it jumps to the last selected item or the top of the listview.
Multiselect is set to True (needs to be that way for other part of program).
Any ideas on how to alter code to get arrow keys functioning properly?
Code Below:
'Searches the customer table for a specific customer
lstCustomer.FullRowSelect = True
lstCustomer.SelectedItems.Clear()
Dim search As String = txtCustomerSearch.Text.Trim
If search <> "" And e.KeyValue = Keys.Enter Then
Dim founditem As ListViewItem
founditem = lstCustomer.FindItemWithText(search, False, 0, True)
If (founditem IsNot Nothing) Then
lstCustomer.Focus()
founditem.Selected = True
lstCustomer.TopItem = founditem
End If
End If
Thanks,
Caleb
The code currently finds the correct row/value. The problem is that once the an item/row is selected and the down (or up) arrow is pushed the listview does not
select the next item. Instead, it jumps to the last selected item or the top of the listview.
Multiselect is set to True (needs to be that way for other part of program).
Any ideas on how to alter code to get arrow keys functioning properly?
Code Below:
'Searches the customer table for a specific customer
lstCustomer.FullRowSelect = True
lstCustomer.SelectedItems.Clear()
Dim search As String = txtCustomerSearch.Text.Trim
If search <> "" And e.KeyValue = Keys.Enter Then
Dim founditem As ListViewItem
founditem = lstCustomer.FindItemWithText(search, False, 0, True)
If (founditem IsNot Nothing) Then
lstCustomer.Focus()
founditem.Selected = True
lstCustomer.TopItem = founditem
End If
End If
Thanks,
Caleb