actualizar mientras escribo en textbox un listbox con tabla nativa de vfp

854 views
Skip to first unread message

Saúl Piña Hdz

unread,
Jul 1, 2013, 10:44:18 AM7/1/13
to mundovis...@googlegroups.com
Buenos dias!

Disculpen, alugo de uds me podria ayudar para lograr que en un listbox con tablas nativas de vfp se vaya actualizando mientras voy escribiendo en un textbox?
Sé que es en el evento nteractivechange del textbox, pero no logro que los datos del listbox se muevan mientras escribo.

gracias!

Analyzer

unread,
Jul 1, 2013, 12:34:15 PM7/1/13
to mundovis...@googlegroups.com
Y ni con un do while te lo has logrado?..

Do while .t.



Saludos!


--
_______________________________________________________________
Has recibido este mensaje porque estás suscrito al Grupo "Mundo Visual
FoxPro" de Grupos de Google.
 
Para anular la suscripción a este grupo, envía un mensaje a:
mundovisualfox...@googlegroups.com
---
Has recibido este mensaje porque estás suscrito al grupo "Mundo Visual FoxPro" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a mundovisualfox...@googlegroups.com.
Para obtener más opciones, visita https://groups.google.com/groups/opt_out.
 
 

HernanCano

unread,
Jul 1, 2013, 8:28:13 PM7/1/13
to mundovis...@googlegroups.com
>>>>...se muevan....
¿"Se muevan"? ¿Qué es "Se muevan"?

Saúl Piña Hdz

unread,
Jul 2, 2013, 11:50:17 AM7/2/13
to mundovis...@googlegroups.com
se muevan, es decir, se actualice el listbox con las coincidencias, segun los caracteres que vayan ingresando en el textbox. algo muy similar "busqueda incremental" gracias!

Adrian Velazquez

unread,
Jul 3, 2013, 5:59:05 PM7/3/13
to mundovis...@googlegroups.com
Hola!

Yo normalmente lo hago en el "Interactive Change" de mi textbox:

select mitabla 
set filter to 
set filter to this.value $ mitabla.campo1+mitabla.campo2+etc. depende de los campos que tengas en tu lista
milista.refresh

saludos.



El 2 de julio de 2013 10:50, Saúl Piña Hdz <vfxpro...@gmail.com> escribió:
se muevan, es decir, se actualice el listbox con las coincidencias, segun los caracteres que vayan ingresando en el textbox. algo muy similar "busqueda incremental" gracias!

Misael Rocha P

unread,
Jul 3, 2013, 8:16:47 PM7/3/13
to mundovis...@googlegroups.com
Buens tardes, asi lo tengo yo y me funciona:
 
 
vas a poner el siguiente código en los siguiente eventos del formulario y listbox , haces la prueba:
 
EN EL EVENTO INIT DEL FORMULARIO
primeramente debes de seleccionar la tabla para enviarla a un cursor con tus condiciones el
 
 

SELECT TUSCAMPOS FROM TUTABLA ;
WHERE TUCONDICION INTO CURSOR MICURSOR NOFILTER

 
EN EL EVENTO GOTFOCUS DEL LISTBOX
 
this.Value=""
Local cFile, cCampo
Thisform.combo1.lcaps = Capslock()
If Capslock() = .F.
Capslock(.T.) && Fuerzo a mayúsculas
Endif
_Incseek = 0.50
SELECT MICURSOR
cFile = 'MICURSOR'   && Tabla o cursor
cField = 'CAMPO'  && Campo de la tabla
nLong = LEN(&cField)  && Longitud del campo
&& Debemos respetar la longitud original del campo
cCampo = [PADR(upper(ltrim(&cField)), nLong, ' ')]
Select &cCampo As cDato From &cFile Distinct Where !Empty(&cCampo) ;
order By cDato Into Cursor curcombo NOFILTER
thisform.combo1.RowSource = 'curcombo'  && Origen de Datos
Keyboard '{ALT+DNARROW}'  && Desplegamos lista
IF !EMPTY(thisform.combo1.DisplayValue)
 *
 cTexto = ALLTRIM(thisform.combo1.DisplayValue)
 FOR yy = 1 TO LEN(cTexto)
  cLetra = SUBSTR(cTexto, yy, 1)
  KEYBOARD cLetra
 ENDFOR
 *
ENDIF
 
 
EN EL EVENTO KEYPRESS DEL LISTBOX
 

If Between(nKeyCode, 32, 122)  OR nKeyCode = 209 && la 'Ñ'
 *
 * Primero comprueba la lista
 For X=1 To This.ListCount
 
  If Upper(Substr(This.List(X), 1, This.SelStart+1)) == ;
   upper(Substr(This.Text, 1, This.SelStart)+Chr(nKeyCode))
   NCURPOS = This.SelStart + 1
   This.Value = This.List(X)
   This.SelStart = NCURPOS
   This.SelLength = Len(ltrim(This.List(X))) - NCURPOS
   This.Comment = SUBSTR(This.List(X),1,NCURPOS)
   *
   Nodefault
   Exit
  Endif
  
 Next X

 *
 * Si no está en la lista
 If X > This.ListCount
  NCURPOS = LEN(this.Comment) + 1
  This.Comment = This.Comment + CHR(nKeyCode)
  This.DisplayValue = This.Comment
  This.SelStart = NCURPOS
  nodefault
 ENDIF
 *
ENDIF
* Si pulsamos Retroceso o flecha izda.
IF nKeyCode = 127 OR nKeyCode = 19
 NCURPOS = LEN(This.Comment) -1
 IF NCURPOS < 0
  NCURPOS = 0
 ENDIF
 
 This.Comment = LEFT(This.Comment, NCURPOS)
 This.DisplayValue = This.Comment
 this.SelStart = NCURPOS
 nodefault
ENDIF
* Si pulsamos 'Inicio'
IF nKeyCode = 1
 NCURPOS = 0
 this.SelStart = NCURPOS
 this.Comment = LEFT(this.DisplayValue, NCURPOS)
 this.SelLength = LEN(this.DisplayValue) - NCURPOS
 nodefault
ENDIF
* Si pulsamos 'Fin'
IF nKeyCode = 6
 NCURPOS = LEN(ALLTRIM(this.DisplayValue))
 this.Comment = ALLTRIM(this.DisplayValue)
 this.SelStart = NCURPOS
 this.SelLength = 0
 nodefault
ENDIF
EN EL EVENTO INIT DEL LISTBOX
 
IF PEMSTATUS(this,'lCaps',5) = .f.
 WITH this
  .addproperty('lCaps',.f.)
 endwith
ENDIF
this.Comment = ''
 
 
y no usas en lo absoluto el interactivechange y tu listbox tendrá las coincidencias de las que hablas...
 
 
 
Saludos, espero te sirva!
Reply all
Reply to author
Forward
0 new messages