Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Find / Find Next Dialog

Posted on 2002-07-25
4
Medium Priority
?
140 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 120 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

824 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