1. List with Quick Find?
Hi all,
Some advise please!
How would one go about having a list of text (sortedList) and creating a
control at the bottom where a user can enter text. As the user enters
text the list would scroll to the nearest match.
soterdList
Enter character "T" into search text & scroll to 1st item with "T" in
it.
Enter character "A" into text search & scroll to 1st item containing
"TA".
Preferable not case sensitive.
Thanks
Tony Steward
Come visit me at www.locksdownunder.com
2. Re: List with Quick Find?
Tony Steward wrote:
> How would one go about having a list of text
> (sortedList) and creating a control at the bottom
> where a user can enter text. As the user enters
> text the list would scroll to the nearest match.
The onChange event of the SearchText control is the place to put the hook.
Try this (untested):
procedure onChange_SearchText()
integer index
sequence text
-- get the new text value
text = getText( SearchText )
-- search the SortedList
index = 0
for i = 1 to getCount( SortedList ) do
if match( text, getItem( SortedList, i ) = 1 then
-- found a match
index = i
elsif index then
-- went too far
exit
end if
end for
-- set focus to last match
setIndex( SortedList, index )
end procedure
-- David Cuny
3. Re: List with Quick Find?
I had written:
> procedure onChange_SearchText()
Ooops. This is *probably* better (but still untested):
procedure onChange_SearchText()
sequence text
-- get the new text value
text = getText( SearchText )
-- search the SortedList
for i = 1 to getCount( SortedList ) do
if match( text, getItem( SortedList, i ) = 1 then
setIndex( SortedList, i )
return
end if
end for
-- no match
setIndex( SortedList, 0 )
end procedure
-- David Cuny