Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combobox incremental search
Message
De
22/10/2003 07:35:27
 
 
À
16/10/2003 10:15:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00839230
Message ID:
00840957
Vues:
22
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform