Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi TStringGrid Flicker

I am adding multiple rows to a string grid from a CSV file @ runtime, However the StringGrid seems to flicker lots when it is being upadated, I presumed there would be a beginupadate / Endupdate command to stop this. However I cannot find it. Is there another way to stop the flicker when the grid id being updated.

Colin

like image 422
colin Avatar asked Sep 14 '10 19:09

colin


3 Answers

Better late than never... I use WM_SETREDRAW. For example:

...
StringGrid1.Perform(WM_SETREDRAW, 0, 0);
try
  // StringGrid1 is populated with the data here 
finally
  StringGrid1.Perform(WM_SETREDRAW, 1, 0);
  StringGrid1.Invalidate; // important! to force repaint after all
end;
...
like image 99
roumen Avatar answered Nov 16 '22 15:11

roumen


Yes, there is no BeginUpdate/EndUpdate in TStringgrid, but there is per row or per col:

StringGrid1.Rows[0].BeginUpdate;
StringGrid1.Cols[0].BeginUpdate;

like image 2
André Avatar answered Nov 16 '22 14:11

André


These are methods of the `TStrings` object. Use StringGrid1.Rows[i]/Cols[i].BeginUpdate; ... StringGrid1.Rows[i]/Cols[i].EndUpdate;

Update

Have you tried to set DoubleBuffered := true?

like image 1
Andreas Rejbrand Avatar answered Nov 16 '22 14:11

Andreas Rejbrand