domingo, 26 de junio de 2011

Introducir Datos: Textos

SetFocus
Para introducir los datos nos tenemos que mover por los textbox.
Si pulsamos Tab de Jerarquía: (ver gráfica 1, zona del punto 4 rojo)




Podemos ordenar con los botones flecha arriba y flecha abajo el orden de los controles cuando pulsemos la tecla “tabulador”



Para conseguir el efecto de cuando pulso “Enter” o “Return” nos desplacemos al siguiente textbox (el que nos interese para introducir los datos) hay que utilizar el siguiente código:



PUBLIC SUB TextBoxDondeEstoy_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxSiguiente.SetFocus
ENDIF
END



Siendo el TextBoxDondeEstoy , la TextBox donde esta actualemnte el cursor, y TextBoxSiguente el TextBox a donde quiero dirigir el cursor cuando abandone el actual TextBox.



En nuestro programa seria el siguiente código:
PUBLIC SUB TextBoxDNI_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxNombre.SetFocus
ENDIF
END


PUBLIC SUB TextBoxNombre_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxApellidos.SetFocus
ENDIF
END


PUBLIC SUB TextBoxApellidos_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxEmpresa.SetFocus
ENDIF
END


PUBLIC SUB TextBoxEmpresa_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxPuesto.SetFocus
ENDIF
END


PUBLIC SUB TextBoxPuesto_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxTelfEmpresa.SetFocus
ENDIF
END


PUBLIC SUB TextBoxTelfEmpresa_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxMovilEmpresa.SetFocus
ENDIF
END


PUBLIC SUB TextBoxMovilEmpresa_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxTelfParticular.SetFocus
ENDIF
END


PUBLIC SUB TextBoxTelfParticular_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxMovilParticular.SetFocus
ENDIF
END


PUBLIC SUB TextBoxMovilParticular_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxFax.SetFocus
ENDIF
END


PUBLIC SUB TextBoxFax_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxCorreo.SetFocus
ENDIF
END


PUBLIC SUB TextBoxCorreo_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxFecha.SetFocus
ENDIF
END


PUBLIC SUB TextBoxFecha_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxWEB.SetFocus
ENDIF
END


PUBLIC SUB TextBoxWEB_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxDireccion.SetFocus
ENDIF
END


PUBLIC SUB TextBoxDireccion_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
TextBoxObs.SetFocus
ENDIF
END


PUBLIC SUB TextBoxObs_KeyPress()
IF Key.code = Key.enter OR Key.code = Key.Return THEN
ButtonAceptar.SetFocus
ENDIF
END

2 comentarios:

  1. Empiezo a perderme. No sé si este código va en el fmain o en alguna subrutina. O en qué parte del fmain se inserta. Yo lo acabo de copiar en el cuerpo principal del fmain.

    ResponderEliminar
  2. Se va añadiendo al codigo dentro de fmain. Se inserta al final (se le va añadiendo al codigo existente).

    Saludos

    ResponderEliminar