473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to search for text in listview?

Tee
Hi,

Need some help with listview, is there a function that can search the
listview for a specified string and return true/false ?
Thanks,
Tee
Nov 21 '05 #1
4 1431
"Tee" schrieb
Need some help with listview, is there a function that can search the
listview for a specified string and return true/false ?


Private Function SearchListViewText( _
ByVal searchString As String) As Boolean

For Each lvi As ListViewItem In myListView.Items
If lvi.Text = searchString Then
Return True
Else
For Each lviSub As ListViewItem.ListViewSubItem In lvi.SubItems
If lviSub.Text = searchString Then
Return True
End If
Next
End If
Next
Return False
End Function

Cheers

Arne Janning
Nov 21 '05 #2
dim i as integer

i = myListViewName.Items.IndexOf(myText)

I will return the index if myText is found and -1 if not

"Tee" wrote:
Hi,

Need some help with listview, is there a function that can search the
listview for a specified string and return true/false ?
Thanks,
Tee

Nov 21 '05 #3
Tee
Thanks for your reply.
I thought there's a function that allow us to do so.
But seems like we have to create our own. Which is good as well.

Thanks.
"Arne Janning" <sp*****************@msn.com> wrote in message
news:uJ**************@TK2MSFTNGP15.phx.gbl...
"Tee" schrieb
Need some help with listview, is there a function that can search the
listview for a specified string and return true/false ?
Private Function SearchListViewText( _
ByVal searchString As String) As Boolean

For Each lvi As ListViewItem In myListView.Items
If lvi.Text = searchString Then
Return True
Else
For Each lviSub As ListViewItem.ListViewSubItem In

lvi.SubItems If lviSub.Text = searchString Then
Return True
End If
Next
End If
Next
Return False
End Function

Cheers

Arne Janning

Nov 21 '05 #4
Tee
Dennis,

How do I make it search for subitems ?

Thanks.
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
dim i as integer

i = myListViewName.Items.IndexOf(myText)

I will return the index if myText is found and -1 if not

"Tee" wrote:
Hi,

Need some help with listview, is there a function that can search the
listview for a specified string and return true/false ?
Thanks,
Tee

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jon Ripley | last post by:
Using VB6 (for two weeks!) I could get a ListBox search working perfectly but with a ListView it has completely stumped me. I've not found any previous posts that have helped :( The user...
2
by: David | last post by:
Hello. In listview I have 3 collumns. How can I read text from 2rd ITEM - 2nd Subitem Example: Mark PEter June HEllo By All Sony Philips Panasonic This is listview:
2
by: George | last post by:
Hello, I want to update an item in a listview, to perform this I search the items collection to find the item with the corresponding text. Is there a more efficient way to perform this? In a...
0
by: sonu | last post by:
Hi all, I have a listview control which has four columns like { Col1, Col2, Col3, Col4}. I add data in listview like this, dim lvitem as listviewItem
2
by: jmDesktop | last post by:
I have two listview controls. I have three items of text. I can drag and drop the listview items between each other, back and forth. But the images from the imagelist do not copy over from...
1
by: Luqman | last post by:
I am using VS 2008, and I am looking for some code which puts live search capability to GridView or ListView 3.5. Just like Yahoo search engine text box, you start typing anything in textbox and it...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
2
by: sajjadlove | last post by:
I want that search in the listView by enter a text in the TextBox and use the textBox_TextChange event then refresh listView items..... please F1.....
3
by: yogarajan | last post by:
Dear Friends i am devloping for search box it is woking good i want highlight my search text. My original text is Mixed case (Lower case and upper case) my search text is lower case means how can...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.