FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
||||
|
||||
Validar y Autocompletar Fecha en un DBEdit
Hola Compañeros del Foro !
Intento validar y autocompletar una fecha dentro de un TDBEdit. Para ello he hecho uso del método descrito en http://delphi.about.com/od/adptips20...ltip0305_3.htm Ligeramente modificado, me ha quedado el siguiente componente denominado TDBDateEdit
Necesito un achuchón final. El autocompletar funciona a la perfección. Pero me sigue saltando un error de 'Invalid Date' si introduzco p.ej. 29/02/2006. En cambio funciona bien, abortando la operación, si p.ej. introduzco en la fecha '89' como día. Por otro lado también me gustaría poder llamar desde algún lado a mi propia rutina de mensaje de error que se encuentra en el programa principal en el cual hago uso del componente modificado, indicando p.ej. en el caso anterior de que se introdujera 29 de Febrero de 2006, u '89' en el día, que la fecha introducida es erronea. Donde debería llamar a dicha rutina propia, o qué valor debería devolver en el componente para interceptar algún evento en mi programa principal ? Como siempre, gracias por vuestra ayuda, y como no, aprovechar esta ocasión para desearos a todos Felices Fiestas y un Próspero Año Nuevo 2007.
__________________
Piensa siempre en positivo ! |
#2
|
||||
|
||||
Pensaba que al introducir '29/02/2006' me ejecutaba
... pero estaba equivocado, y no entra ahí. Funciona correctamente así :
Me queda entonces sólo la pregunta acerca de donde interceptar un posible error en mi programa principal para lanzar mi propio mensaje de error avisando de Fecha Erronea. Entiendo que tengo que cambiar el 'Abort' por algo, pero necesito vuestra ayuda.
__________________
Piensa siempre en positivo ! |
#3
|
||||
|
||||
Creamos un evento para que el usuario del componente pueda asignarlo via el inspector de objetos, lo llamamos OnValidateError.
Después de lanzar el evento dentro de nuestro componente, llamamos a Abort, para que continue.
Tendrás que añadir el Uses DateUtils para que reconozca TryStrToDate. Además está hecho de memoria, así que puede tener algún error en el orden de parámetros al llamar a dicha función. Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente, se lo volveré a explicar hasta que no lo entienda, Gracias. |
#4
|
||||
|
||||
Perfesssto !
Muy agradecido. Lo he dejado de la siguiente manera :
Esto me creo el evento deseado OnValidateError y en él puedo ya llamar a mi propia rutina del programa principal de mensaje de error. De nuevo, muchas gracias Lepe.
__________________
Piensa siempre en positivo ! |
#5
|
||||
|
||||
Hombreeeee, pero cúrratelo un poco más jajajaja.
El parámetro ErrorOn está pensado para decirle al programador (ususario del TDBedit) qué falla en la fecha, si el día (es mayor de 31), el mes (si es mayor de 12), si el día con el més (por ejemplo fallo del 31/02/2003) ya que febrero no tiene 31, etc. Si no quieres usar ese parámetro para nada, borralo de su definición y borra también el parámetro cuando lanzas el evento. Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente, se lo volveré a explicar hasta que no lo entienda, Gracias. |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Validar un Dbedit? | kman | Varios | 10 | 13-03-2007 04:07:11 |
Validar un DBEdit con delphi interbase | servicomp | Conexión con bases de datos | 8 | 06-08-2006 16:27:11 |
validar dbedit | yeison Cristman | Conexión con bases de datos | 1 | 29-07-2006 21:55:56 |
validar en fecha, dia y mes | alcides | Varios | 2 | 08-02-2005 16:29:33 |
como validar datos en el evento onkeypress de un dbedit? | viajero2015 | Varios | 1 | 01-02-2004 21:41:59 |
|