Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incremental Search in Combobox
Message
De
14/01/2000 08:37:14
 
 
À
14/01/2000 06:51:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00318087
Message ID:
00318116
Vues:
17
Hi jOHN.

>> ... So I guess if you want to have style to be 0 so you can add or edit one could have a control button to toggle back and forth... <<

Gag me with an axe < vbg >. No. Set up your combo class as style = 0-drop down combo. Add a custom method called HandleKey and cll it from the combo's KeyPress like this:
*** handle the key...IOW, find the closest match in the list
IF ( nKeyCode > 31 AND nKeyCode < 128 ) OR ( nKeyCode = 7 )
  *** We need this to update the combo's display value
  IF This.HandleKey( nKeyCode )
    NODEFAULT
  ENDIF	
ENDIF
And this 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
The code in the combo's valid to decide whether or not you have added a new entry:
IF This.ListIndex = 0 AND !EMPTY( This.DisplayValue )
   *** New entry...add it to the underlying RowSource
   *** and save the value of the combo so it can be restored
   This.Requery()
   This.Value = < what it was before >
ENDIF
Marcia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform