Delphi TStringGrid Flicker

col*_*lin 9 delphi tstringgrid

我正在从CSV文件@ runtime中向字符串网格添加多行,但是当StringGrid被提升时似乎闪烁很多,我假设会有一个beginupadate/Endupdate命令来阻止它.但是我找不到它.是否有另一种方法可以在更新网格ID时停止闪烁.

科林

rou*_*men 17

迟到总比没好...我用WM_SETREDRAW.例如:

...
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;
...
Run Code Online (Sandbox Code Playgroud)


And*_*and 1

这些是“TStrings”对象的方法。使用 StringGrid1.Rows[i]/Cols[i].BeginUpdate; ... StringGrid1.Rows[i]/Cols[i].EndUpdate;

更新

你尝试过设置DoubleBuffered := true吗?

  • 现在我查看了代码,很明显“TStringGrid”并不是地球上最好的控件。我真的不喜欢这个控件的一件事是它没有主题——它在主题应用程序中看起来很奇怪。您确定不能使用“TListView”吗? (2认同)