Listview search

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Listview search
AnoPem
How can i search in a listview where it dosent matter if the char is upper or lower case?
https://t.me/pump_upp
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Listview search
Dummy1912
hi
there are lots of stuff to find :)
so tell us what kind of data are you wanted to search for?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Listview search
AnoPem
Dummy1912 wrote:
hi
there are lots of stuff to find :)
so tell us what kind of data are you wanted to search for?
I have a listview where i there has been loaded movies like RED but i want the user to be able to just search red and it will find it instead of having to search RED with upper case
https://t.me/pump_upp
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Listview search
Dummy1912
what about this?
Code: Select all
    Private Sub searchBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles searchBox.KeyPress
        If Asc(e.KeyChar) = 13 Then

Dim itm As ListViewItem
Dim i As Integer

For i = 0 To lvUser.Items.Count - 1
lvUser.Items(i).Selected = False
lvUser.Items(i).BackColor = Color.White
Next

With lvUser
itm = .FindItemWithText(searchBox.Text, False, 0, True)


If Not itm Is Nothing Then

'.TopItem = itm
.Items.Item(itm.Index).BackColor = Color.BurlyWood
.Items.Item(itm.Index).EnsureVisible()
Else
MsgBox("No Record Found!")
For i = 0 To lvUser.Items.Count - 1
lvUser.Items(i).Selected = False
lvUser.Items(i).BackColor = Color.White
Next
.Items(0).EnsureVisible()
.Items.Item(0).BackColor = Color.BurlyWood

searchBox.SelectionStart = 0
searchBox.SelectionLength = Len(searchBox.Text)
searchBox.Focus()
End If
End With
itm = Nothing
End If
End Sub
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Listview search
AnoPem
Dummy1912 wrote:
what about this?
Code: Select all
    Private Sub searchBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles searchBox.KeyPress
        If Asc(e.KeyChar) = 13 Then

Dim itm As ListViewItem
Dim i As Integer

For i = 0 To lvUser.Items.Count - 1
lvUser.Items(i).Selected = False
lvUser.Items(i).BackColor = Color.White
Next

With lvUser
itm = .FindItemWithText(searchBox.Text, False, 0, True)


If Not itm Is Nothing Then

'.TopItem = itm
.Items.Item(itm.Index).BackColor = Color.BurlyWood
.Items.Item(itm.Index).EnsureVisible()
Else
MsgBox("No Record Found!")
For i = 0 To lvUser.Items.Count - 1
lvUser.Items(i).Selected = False
lvUser.Items(i).BackColor = Color.White
Next
.Items(0).EnsureVisible()
.Items.Item(0).BackColor = Color.BurlyWood

searchBox.SelectionStart = 0
searchBox.SelectionLength = Len(searchBox.Text)
searchBox.Focus()
End If
End With
itm = Nothing
End If
End Sub

How would i use this dunnno;
https://t.me/pump_upp
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Listview search
Dummy1912
just copy this code
just add a searchbox --> textbox
type something and press return key

replace lvUser with your listview
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
6 posts Page 1 of 1
Return to “Coding Help & Support”