Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListView Activex Control

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
0
0
AU
How do I use the "FindItem" method?

When I create the entries in the listview, I add an unique key from the cursor that provides the records for the listview
I also need to be able to move to the record in the listview control when the cursor in the main table is moved (locating correct row using the unique key)

I can't find any documentation on the method

Code:
*** ActiveX Control Method ***
LPARAMETERS sz, where, index, fpartial
 
Another thing you can refer to inside VFP is the Object Browser. If you open the type library for the Microsoft Listview Control, which I find in v5 and v6 on my computer, you will find a list of all methods, properties, events and on the highest level in the root node the status bar tells you the detailed reference on the v5 ComctlLib is in a help file "comctl1.hlp" and v6 MSComctLib is documented in cmctl198.chm.

The object browser also detects these help files are not installed, and that is so, because these help files don't come with VFP, they come with MSDN Library, should be MSDN of years 1998 and earlier. Those should have come with Visual Studio 6 and 5. You might try to find these files online or look into your archive of MS stuff.

Bye, Olaf.
 
I've never used the FindItem method. I usually loop through the items, looking for the unique key in question:

Code:
FOR EACH loItem IN this.ListItems
  IF loItem.Key = <the key I am looking for>
    * this is the item I am looking for
  ENDIF
ENDFOR

You can also use loItem.Index if you know the index of the item you are looking for.

This might not be as fast as FindItem, but it's a fairly simple approach.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks,
Olaf - I had Googled extensively, and I found some examples in VB, but a VFP example on the net would have been helpful
I forgot to say that this a multicolumn listview, not sure if this effects the key or index
I did try the method extensively before posting , but it would always return null
eg
Code:
lcFind=thisform.sitelist1._listview1.findItem(lcKey,1,1,1)
MESSAGEBOX(lcFind)


Mike - I will give this a go.

 
The documentation of the method says ( you will get an object back, if an item is found, not a text. The first thing you should specify is, what version of the ListView control you're using in your form. Aside of that, I'd say Mike's solution should work good for you.

>findItem(lcKey,1,1,1)
As you want to find an item by it's tag (or key) and not it's text or subitem, the documentation says the second parameter should be 2, not 1.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top