Solved

Find / Find Next Dialog

Posted on 2002-07-25
4
130 Views
Last Modified: 2010-05-02
I have a ListView object .
And I need to write a Find/Find next Dialog for it.
It's mean to find some text in this list view object.
And I don't know ,how.
Maybe someone can help me .
Thanks.
0
Comment
Question by:Inga_dusha
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Nazdor earned 30 total points
ID: 7176918
Easiest option is to use a loop to cycle through the listview items, for example:

dim li as item

for each li in listview1
    if li.index >= lngStartPos then
        if li.text = strSearch then
            li.selected = true
            exit for
        end if
    end if
next


Then supply strSearch to search for and lngStartPos for where to start (eg listview1.selecteditem.index)

If you need to search again from the beginning, then add another loop with "if li.index < lngstartpos then..."


Of course, this only searches the .text (primary column) if you need to search the subitems, then you'll have to loop through them within the above loop.  Depends on whether you want to search by column or row... (row is easier)


0
 
LVL 5

Expert Comment

by:RainUK
ID: 7177240
You could use the acutal Find method of the listview control:

Dim lstItemX as ListItem
Dim iIndex as integer

Set lstItemX = ListView1.Find("MyName",lvwSubItem,1,lvwWholeWord)

If lstItemX Is Nothing Then
   ' No item found
Else
   ' Item was found
   debug.Print "Index of item where MyName was found = " & lstItem.Index

   ' Here you would put up a dialogue saying do you want  to find next.
   ' If the user did want to find next then you would bein the search at the index where you found the last item
   Set lstItemX = ListView1.Find("MyName",lvwSubItem,iIndex,lvwWholeWord)

End If


This is just a simple bit of code to give you an idea of how to use the list views 'Find' Method. Look up the properties you need to pass it in MSDN.
0
 
LVL 5

Expert Comment

by:RainUK
ID: 7177244
Sorry when you find the first item you should set:

iIndex = lstItemX.Index
iIndex = Index + 1

Then pass the value to Find Method of listview, to being the search fromt there.
0
 

Author Comment

by:Inga_dusha
ID: 7177464
Thanks ,RainUK , Nazdor !
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now