[Lazarus] Stringgrid woes...

Jesus Reyes jesusrmx at yahoo.com.mx
Fri Mar 13 23:06:30 CET 2009





--- El vie 13-mar-09, Michael Van Canneyt <michael at freepascal.org> escribió:
> >   if grid.Modified then begin
> >     [Do validation on col,row cell. Revert changes if
> not validated, etc]
> >     grid.Modified := false;
> >   end;
> 
> The problem is that the actual data is not in the grid
> cells, so reverting it would not be that easy.
> Is there a way to force the grid to save the data ? That
> would help, actually...

if grid.Modified=true when OnEditingDone triggers, then the cell has been
modified and the data is in cell (ok, that it could be any other cell which was modified it's true but that is a problem of program) and grid.cell[aCol,aRow] has the value.

the only problem is that grid.Modified needs to be reset to false manually, other way the grid doesn't know when the is appropiated to set modified := true.

> 
> In Delphi, Setting 
> 
>   EditorMode:=False;
> 
> Saves the data (setedittext is called again). In Lazarus,
> it is not called. 
> 

I'm taking notes.

> I think it would also be a good idea to have an event which
> helps to validate the data.
> 
> Something like
> 
> Procedure TForm1.ValidateEntry(Sender : TObject; ACol,ARow
> : Integer; Var Value : String);
> 
> begin
>   // Do some things, possibly modify Value or raise
> exception.
> end;
> 
> Which is called only once, when the data is saved finally. 
> Currently, it's hard to do proper validation in a grid.
> Well, in my opinion of course...

I thought the same and that's why I introduced grid.modified which has served me very well. But I agree that an event to do validation would be best, I will try to do something about it.

> 
> Michael.

Jesus Reyes A.

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 




More information about the Lazarus mailing list