PDA

Ver la Versión Completa : Problema al leer un campo del dbgrid


lejia
10-10-2007, 10:53:34
;)hola amigos, mi problema son varios y voy resolviendo gracias a la ayuda de ustedes, gracias de nuevo..
Tengo un dbgrid, y cuando modifico un campo no se guarda,, he leido por ahi, k tengo que hacer un post, pero no se cuando tengo que hacer el post, porque no encuentro una propiedad que me diga salirdecelda por ejemplo. y como seria la funcion post?.. he visto que puedo usar un navigator, y postear en el.. pero quiero que sea en el mismo dbgrid, cuando cambie el valor y le de a intro.. otra cosa ke kiero, es como leo ese dato que he cambiado y guardarlo en una varible, proque despues kiero hacerle operaciones y modificar ese valor en otro campo del grid. lo que quiero hacer es cambiar el valor de un producto en el grid en euros, y que en la columna de de pesetas salga ya cambiado el valor, gracias, pero no se que funcioens usar, y ni cuando, porque no encuentro un salirdecelda, o algo asi,

Ivanzinho
10-10-2007, 12:59:44
Puedes usar el evento OnValidate del TField

Un saúdo.

lejia
10-10-2007, 13:28:24
si, pero dentro de que evento del dbgrid, leo el onvalidate, porque lo quiero que cuando termine de editar una celda.?

Ivanzinho
10-10-2007, 15:30:47
si, pero dentro de que evento del dbgrid, leo el onvalidate, porque lo quiero que cuando termine de editar una celda.?

No lo tienes que leer dentro de ningun evento del dbgrid, es un evento que se ejecuta antes de que el valor sea almacenado en el buffer.

Occurs just before the data is written to the record buffer.

type TFieldNotifyEvent = procedure(Sender: TField) of object;
property OnValidate: TFieldNotifyEvent;

Description

Write an OnValidate event handler to validate changes made to the data in the field, just before the data is written to the current record buffer. The EditMask property allows validation of the data on a character by character basis while it is being entered by the user. OnValidate allows an application to validate the data as a whole.

When the value of a field component is assigned programmatically, validation by the EditMask is bypassed, since there is no data-aware control to enforce adherence to the mask. OnValidate allows an application to validate such data before it is posted to the database table.

To reject the current value of the field from the OnValidate event handler, raise an exception.

When writing the value of a field to the current record buffer, the following steps occur:

1 The OnValidate event handler is called to validate the data.
2 If the OnValidate event handler does not raise an exception, the data is written to the current record buffer.
3 If writing the data does not raise an exception, the OnChange event handler is called to allow a response to the change.