*_________________________Explicación____________________________________
* La idea de este Código es hacer una 'especie' de busqueda
* predictivo.
* Utilizando un Seek() se consige la busqueda,pero se complica
* a la hora de seleccionar el texto que continua la frase (Por eso el
* Bucle 'IF THISFORM.CONTROL=.F.').
* El bucle 'IF (LASTKEY()=7)or(LASTKEY()=127)' controla que no se ejecute
* la busqueda y seleccion cuando se oprime las teclas 'Supr y Del'
* Aqui se utiliza una grilla y una tabla, pero bien puede ser un
* archivo de texto u otro
* Dos variables o propiedades nuevas agregale al form
* (control=0 y contador=.f.) , 1 textbox y una grilla con la
* propiedad 'HighlightStyle=2'
*______________________ Código del InteractiveChange_____________________
IF EMPTY(this.Value)
thisform.contador=0
endif
IF (LASTKEY()=7)or(LASTKEY()=127)
IF LASTKEY()=127
thisform.contador=LEN(ALLTRIM(this.Value))
ENDIF
ELSE
IF thisform.control=.f.
thisform.contador=thisform.contador+1
thisform.control=.t.
*_______=SEEK(alltrim(LO QUE BUSCAS),'EN LA TABLA',ALLTRIM('MEDIANTE EL INDICE'))
=SEEK(alltrim(this.value),'articulos',ALLTRIM('caarticulo'))
thisform.basegrid1.Refresh
this.value=ALLTRIM(this.value)+(RIGHT(alltrim(articulos.articulo), LEN(alltrim(articulos.articulo))-LEN(alltrim(this.value))))
this.HideSelection= .T.
thisform.LockScreen= .T.
this.SelStart = thisform.contador
this.SelLength = LEN(ALLTRIM(this.Value))
this.HideSelection= .f.
thisform.LockScreen= .f.
ELSE
thisform.contador=thisform.contador+1
thisform.control=.f.
*_______=SEEK(alltrim(LO QUE BUSCAS),'EN LA TABLA',ALLTRIM('MEDIANTE EL INDICE'))
=SEEK(alltrim(this.value),'articulos',ALLTRIM('caarticulo'))
thisform.basegrid1.Refresh
this.value=ALLTRIM(this.value)+(RIGHT(alltrim(articulos.articulo), LEN(alltrim(articulos.articulo))-LEN(alltrim(this.value))))
this.HideSelection= .T.
thisform.LockScreen= .T.
this.SelStart = thisform.contador
this.SelLength = LEN(ALLTRIM(this.Value))
this.HideSelection= .f.
thisform.LockScreen= .f.
ENDIF
ENDIF
*___________________________Código del Keypres_________________________
* En este caso con ENTER se incluye en el textbox el texto seleccionado
* Quedaria Mejor con nkeycode=4 'Flecha Derecha', pero = funciona
IF nkeycode=13
this.HideSelection= .T.
thisform.LockScreen= .T.
this.SelStart = 0
this.SelLength = 0
this.HideSelection= .f.
thisform.LockScreen= .f.
ENDIF
** Si alguien tiene una manera mas sencilla de hacer esto, favor de
** compartirlo