Solved

Find / Find Next Dialog

Posted on 2002-07-25
4
132 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

929 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

12 Experts available now in Live!

Get 1:1 Help Now