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.
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
How can i search in a listview where it dosent matter if the char is upper or lower case?
hi
there are lots of stuff to find
so tell us what kind of data are you wanted to search for?
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
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
Dummy1912 wrote:hiI 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
there are lots of stuff to find
so tell us what kind of data are you wanted to search for?
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
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
Dummy1912 wrote:what about this?
Code: Select allPrivate 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;
just copy this code
just add a searchbox --> textbox
type something and press return key
replace lvUser with your listview
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
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
Copyright Information
Copyright © Codenstuff.com 2020 - 2023