Ver Mensaje Individual
  #2  
Antiguo 09-07-2013
Avatar de ozsWizzard
ozsWizzard ozsWizzard is offline
Miembro
 
Registrado: may 2004
Ubicación: Murcia
Posts: 190
Reputación: 23
ozsWizzard Va por buen camino
Solución 1
En el DataSet hay un beforesinsert y un beforeupdate, y validas antes de grabar en la tabla.

Eso se me ocurre.

Solución 2
Yo tengo un StringGrid (porque dices una grilla y he asumido que es un DBGrid) al que le creé el evento "ExitCell", pero esta solución te hace cargar los datos a mano en el Grid

Definición, justo después del uses
Código Delphi [-]
  TExitCell = procedure(Sender: TObject; const ACol, ARow: Integer) of object;

  TStringGrid = class(Vcl.Grids.TStringGrid)
      private
         FCol:    Integer;
         FRow:    Integer;
         FEntrar: Boolean;
         EditCel: Boolean;

         FExitCell:    TExitCell;
      protected
         function SelectCell(ACol, ARow: LongInt): Boolean; override;

         procedure DoEnter; override;
         procedure DoExit; override;
      public
         property ColAux: Integer read FCol    write FCol    default 0;
         property RowAux: Integer read FRow    write FRow    default 0;
         property Entrar: Boolean read FEntrar write FEntrar;

         //Eventos
         property OnExitCell: TExitCell read FExitCell write FExitCell;
  end;

Implementación
Código Delphi [-]
{ TStringGrid }

procedure TStringGrid.DoEnter;
begin
   inherited;
   ColAux := Col;
   RowAux := Row;
   Entrar := true;
end;

procedure TStringGrid.DoExit;
begin
   if Assigned(OnExitCell) then OnExitCell(Self, ColAux, RowAux);
   inherited;
end;

function TStringGrid.SelectCell(ACol, ARow: LongInt): Boolean;
begin
   //Para no repetir el evento OnExitCell cuando se entra al StringGrid
   if Entrar then
      Entrar := false
   else
      if Assigned(OnExitCell) then OnExitCell(Self, ColAux, RowAux);
   inherited;
   ColAux := ACol;
   RowAux := ARow;

   EditCel := false;
   Result := true;
end;


Solamente falta crear el procedimiento y asignarlo en tiempo de ejecución a la propiedad "OnExitCell".

También se puede meter en una unidad y ponerla siempre después de Grids.
__________________
La Madurez se llama...
~~~Gaia~~~
Responder Con Cita