1 Replies - 200 Views - Last Post: 12 July 2014 - 12:38 AM Rate Topic: -----

#1 bubu31  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 04-July 14

how to search for more than one item

Posted 11 July 2014 - 11:51 PM

I need search more than 1 item, because there is some same values in my listview Columns.

this below code will only shows one item only. But i want to display more than one item.

  Function FindItem(ByVal LV As ListView, ByVal TextToFind As String) As Integer

        Dim IntList As New List(Of Integer)

        ' Loop through LVs ListViewItems.
        For i As Integer = 0 To LV.Items.Count - 1
            If Trim(LV.Items(i).Text) = Trim(TextToFind) Then
           
                Return (i)
            End If

            For subitem As Integer = 0 To LV.Items(i).SubItems.Count - 1
                If Trim(LV.Items(i).SubItems(subitem).Text) = Trim(TextToFind) Then
                   
                    Return (i)
                End If
            Next
        Next
        ' If not found, then return -1.

        Return -1

    End Function





 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        ListView1.MultiSelect = False

        ListView1.FullRowSelect = True


        Dim checkInt As Integer = FindItem(ListView1, keyword.Text)

        If checkInt <> -1 Then
            ListView1.Items(checkInt).Selected = True
            ListView1.Focus()
            ListView1.SelectedItems(0).EnsureVisible()
        Else
            Label1.Text = "Search string not found"
        End If

    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: how to search for more than one item

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,668
  • Joined: 27-December 08

Re: how to search for more than one item

Posted 12 July 2014 - 12:38 AM

Please stop duplicate posting. You have an open thread on this. You should understand that most of our members are in the United States, where it is somewhere between 12:30-3:30 AM. Many folks are asleep. It is not necessary to keep posting threads and bumping your threads to draw more attention, and it is a bit rude to do so.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1