Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox incremental search
Message
From
22/10/2003 08:35:18
 
 
To
22/10/2003 07:35:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00839230
Message ID:
00840976
Views:
19
Thanks for the reply I will try your code

Michel

>Hello Michel.
>
>I found that the combobox must be open and after the incremental search work but i want that the user just type in the combobox without opening it and the combo will search for the value as the user type.
>
>With a combo of style=0(drop down combo), if you want a "quick fill" combo, you need to write a little bit of code. Add a custom method to your combo and call it HandleKey and call it from the combo's InteractiveChange() like this:
>
>
>*** handle the key...IOW, find the closest match in the list
>IF This.SelStart > 0
>  IF ( LASTKEY() > 31 AND LASTKEY() < 128 ) OR ( LASTKEY() = 7 )
>    This.HandleKey()
>  ENDIF
>ENDIF
>
>
>This code goes in handlekey():
>
>
>LOCAL lcSofar, lnSelStart, lnSelLength, lnRow
>
>WITH This
>  *** Handle backspace key
>  IF LASTKEY() = 127
>    .SelStart = .SelStart - 1
>  ENDIF	
>  *** Get the value typed in so far
>  lnSelStart = .SelStart
>  lcSofar =  LEFT( .DisplayValue, lnSelStart )
>  *** Find a match in column #1 of the combo's internal list
>  FOR lnRow = 1 TO .ListCount
>    IF UPPER( .List[ lnRow, 1 ] ) = UPPER( lcSoFar )
>      .ListIndex = lnRow
>      EXIT
>    ENDIF
>  ENDFOR		
>  *** Highlight the portion of the value after the insertion point
>  .SelStart = lnSelStart
>  lnSelLength = LEN( ALLTRIM( .DisplayValue ) ) - lnSelStart
>  IF lnSelLength > 0
>    .SelLength =  lnSelLength	
>  ENDIF	
>ENDWITH
>
Previous
Reply
Map
View

Click here to load this message in the networking platform