View Single Post
 
Old 12-16-2013, 08:29 PM
CJacob CJacob is offline
Newcomer
 
Join Date: Nov 2013
Posts: 2
Question Filter List view

Here's my code. How can i filter the listview? The items from the list view is from ms access.

Code:
Sub searchlstv()
        ListView1.BeginUpdate()
        conn = New ADODB.Connection
        constr = ("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\Database3.mdb")
        conn.Open(constr)
        Dim rs100 As New ADODB.Recordset
        Dim rs2 As New ADODB.Recordset
        rs100.Open("SELECT * FROM tbl_doc_info", conn, ADODB.CursorTypeEnum.adOpenDynamic)
        If Not TextBox1.Text = "" Then
            
        End If
        If Not TextBox2.Text = "" Then
            Dim a As String = Nothing
            Dim itm As ListViewItem = Nothing
            rs100.MoveFirst()
            Do Until rs100.EOF
                If rs100.Fields("docrevno").Value.ToString.ToLower Like CStr("*" & TextBox2.Text.ToLower & "*") Then
                    rs2.Open("SELECT * FROM tbl_files_info WHERE docno LIKE '" & (CStr(rs100.Fields("docno").Value)) & "'", conn, ADODB.CursorTypeEnum.adOpenDynamic)
                   
                    With ListView1
                        itm =   .FindItemWithText(CStr(rs100.Fields("docno").Value.ToString), False, 0, True)
                        If Not itm Is Nothing Then
                            .Items.Item(itm.Index).Selected = True
                        End If
                    End With
                    itm = Nothing
                    rs2.Close()
                End If
                rs100.MoveNext()
            Loop
         
        End If
This code doesn't filter the listview.

Last edited by CJacob; 12-16-2013 at 10:11 PM.
Reply With Quote