jxharding
asked on
narrow down items in listview,according to user input
narrow down items in listview,according to user input
vb6sp5
i have a listview that gets input from a recordset, and then adds every recordsets item into the listview
eg.
aa1
aa2
ab1
ab2
now i have a textbox above the listview in which the user can narrow down the items in the listview,
thus, if the user was to type "aa" into the textbox, all items in the listview starting with "aa"
will be displayed in the listbox,and all the others will be (hidden? / deleted)
now i know i will use textbox's change event,
heres what i tried
Private Sub txtPCode_Change()
Dim inputLength As Integer
inputLength = Len(txtPCode.text)
Dim rsListItems As New ADODB.Recordset
For i = 1 To lstCode.ListItems.Count
If Left(lstCode.ListItems(i). text, inputLength) <> txtPCode.text Then
'i got to do delete the listitem here
End If
Next i
End Sub
but this is probably stupid, because if the user was to say use backspace in the textbox,all
the records that have just been filtered out, must return again.
e.g. textbox.text = aa
listview.items:
aa1
aa2
but if textbox.text goes from aa to a then
listview.items :
aa1
aa2
ab1
ab2
i guess i should read all the records into the recordset once the list is populated.
can someone please help me with the code on this as well as the filtering process.
vb6sp5
i have a listview that gets input from a recordset, and then adds every recordsets item into the listview
eg.
aa1
aa2
ab1
ab2
now i have a textbox above the listview in which the user can narrow down the items in the listview,
thus, if the user was to type "aa" into the textbox, all items in the listview starting with "aa"
will be displayed in the listbox,and all the others will be (hidden? / deleted)
now i know i will use textbox's change event,
heres what i tried
Private Sub txtPCode_Change()
Dim inputLength As Integer
inputLength = Len(txtPCode.text)
Dim rsListItems As New ADODB.Recordset
For i = 1 To lstCode.ListItems.Count
If Left(lstCode.ListItems(i).
'i got to do delete the listitem here
End If
Next i
End Sub
but this is probably stupid, because if the user was to say use backspace in the textbox,all
the records that have just been filtered out, must return again.
e.g. textbox.text = aa
listview.items:
aa1
aa2
but if textbox.text goes from aa to a then
listview.items :
aa1
aa2
ab1
ab2
i guess i should read all the records into the recordset once the list is populated.
can someone please help me with the code on this as well as the filtering process.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.