10

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

科林

4

4 回答 4

19

迟到总比没有好...我使用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;
...
于 2011-08-17T21:50:28.627 回答
2

是的,TStringgrid 中没有 BeginUpdate/EndUpdate,但每行或每列都有:

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

于 2010-09-15T05:54:37.173 回答
1
这些是 `TStrings` 对象的方法。使用 StringGrid1.Rows[i]/Cols[i].BeginUpdate; ... StringGrid1.Rows[i]/Cols[i].EndUpdate;

更新

你试过设置DoubleBuffered := true吗?

于 2010-09-14T19:36:36.287 回答
-2

您可以使用 Windows 函数 LockWindowUpdate(AHandle) 来阻止控件的刷新,然后使用 LockWindowUpdate(0) 来重新绘制它。

作为句柄传递 Grid.Handle。

于 2010-09-14T21:28:54.593 回答