Solved

Find / Find Next Dialog

Posted on 2002-07-25
4
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month6 days, 9 hours left to enroll

636 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