Solved

Find / Find Next Dialog

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

751 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