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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question concerning Incremental Search - Like Help Index faq184-3842 2

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
I tried that code (written by craigsboyd) and it works fine.
Now I wanted to have this code as an additional feature in a form which I created myself.
But I have problems to integrate that, when I implement a click-button on my form which has the code written by craigsboyd in its click-event.
VPF then says :
"Methods and events cannot contain nested procedures or class defintions"

I am sorry that I am not experienced with classes - but perhaps anyone here could help with a solution to add this useful code by craigsboyd to a form which already exists.

Thanks in advance.
Keep healthy...
Klaus

See faq184-3842

Peace worldwide - it starts here...
 
Hi Klaus,

whenever you edit a method or event in the visual designer, you have to imagine your code written within PROCEDURE method/eventname() and ENDPROC. You can't embed further methods/events within a method/event. This kind of nesting code is not allowed. Even less so a whole class definition with objects and object methods.

The essential code you need from the FAQ is the interactivechange event code for the listbox and textbox. So you have to pick out the code in the interactivechange events and put them into your visual controls interactivechange vents.

On the other side look into the autocomplete feature of a VFP9 textbox, which gives you alternative options by just setting a few properties and having the data the user should be able to incrementally search in a table with a certain structure. Can't tell you from the top of my head, but simply lookup autocomplete in VFP's help.


Chriss
 
The code in the FAQ is completely self-contained. It creates a form, adds a listbox and textbox, and then adds the incremental search functionality.

What you are trying to do is to incorporate that code into an existing form. That's not going to work. Instead of simply copying the code, you should try to understand what it is doing and how it works, and then use those same ideas (not necessarily the same code) in your own application.

That said, there are easier ways of implementing incremental search. My preference would be to use a textbox with its AutoComplete property set to 1 (as suggested by Chris above).

Or, for a simpler implementation, just set the listbox's IncrementalSearch to .T. It's not as flexible as the other methods, but much easier to implement.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you very much, Chris & Mike.
Your suggestions will help me very much.

Greetings from Western-Germany

Klaus


Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top