Re: List with Quick Find?

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu