INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ListBox

Incremental Search - Like Help Index by craigsboyd
Posted: 6 Jul 03 (Edited 18 Feb 05)

Slighthaze = NULL

It works good in help so why not give your users the same ability for your application?  NOTE: There is a small delay when running it since the list of entries is being created randomly.  (Cut-n-paste the code below into a prg file and run it from within VFP)

PUBLIC oForm
 
oForm = CREATEOBJECT("clssearch")
oForm.visible = .t.
 
DEFINE CLASS clssearch AS form
 
 Top = 1
 Left = 0
 Height = 473
 Width = 287
 DoCreate = .T.
 Caption = "Incremental Search"
 WindowState = 0
 Name = "clssearch"

 ADD OBJECT list1 AS listbox WITH ;
  Height = 408, ;
  Left = 12, ;
  Sorted = .T., ;
  Top = 48, ;
  Width = 264, ;
  Name = "List1"

 ADD OBJECT text1 AS textbox WITH ;
  Format = "!K", ;
  Height = 23, ;
  Left = 12, ;
  Top = 12, ;
  Width = 264, ;
  Name = "Text1"
  Format = "!K"
 
 PROCEDURE Init
  LOCAL nCount, nCount2, nWordLength, sItem, nUpper, nLower
  nUpper = 90 &&ASCII
  nLower = 65 &&ASCII
  FOR nCount = 1 to 250
   sItem = ""
   nWordLength = INT((35) * RAND( ) + 1)
   FOR nCount2 = 1 TO nWordLength
    sItem = sItem + CHR(INT((nUpper - nLower + 1) * RAND( ) + nLower))
   ENDFOR
   thisform.List1.additem(sItem)
  NEXT   
 ENDPROC
 
 PROCEDURE Activate
     thisform.text1.setfocus()
 endproc

 PROCEDURE list1.interactivechange
    thisform.text1.value = this.value
    thisform.text1.refresh()
ENDPROC
  
 PROCEDURE text1.interactivechange
  LOCAL nCnt, sSearchFor, nLen
  sSearchFor = ALLTRIM(this.value)
  nLen = LEN(sSearchFor)
  FOR nCnt = 1 TO ThisForm.List1.ListCount
    IF sSearchFor == LEFT(ALLTRIM(ThisForm.List1.List(nCnt)),nLen)
     thisform.List1.Selected(nCnt) = .t.
     thisform.List1.refresh()
     EXIT &&Found one
    endif
  ENDFOR
ENDPROC

ENDDEFINE

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close