Recent

Author Topic: DBGrid update at dataChange  (Read 5125 times)

Mando

  • Full Member
  • ***
  • Posts: 181
DBGrid update at dataChange
« on: November 24, 2010, 10:07:51 am »
Hi

I've a table in firebird database and i use Zeos to access.
I've a datamodule and a form with a dataSource(dtDatos) linked to a zTable on datamodule.
Well, I use this code:

Code: [Select]
procedure TGestionLista.dtDatosDataChange(Sender: TObject; Field: TField);
var a: integer;
begin

  if field=nil then
  begin
    a:=dtDatos.Dataset.RecNo;
    
    self.etRegistros.caption:=format('%d',[a]);

  end;
  
end;        
the intention of this code is to show the current record number in a label (etRegistros),
well, it works fine when scroll the DBgrid one by one, but if i keep pressed the down key, then the grid and the label doesn't repaint, until i release the key. The scroll bar moves.

I tried with a simple counter, a global variable that increment in this procedure, and the behavior is the same.
Also, I tried changing the label by a staticText. Now, the staticText caption is updated, but the grids appears frozen, except the scrollbar.
I inserted a Repaint of the grid, but it's make the process slower.

That is not life or death, but is quite ugly.

Can anyone help me?



« Last Edit: November 24, 2010, 02:16:39 pm by Mando »

 

TinyPortal © 2005-2018