Delphi TStringGrid 闪烁
我正在运行时从 CSV 文件向字符串网格添加多行,但是 StringGrid 在更新时似乎会闪烁很多,我认为会有一个 beginupadate / Endupdate 命令来停止此操作。但是我找不到它。有没有其他方法可以在更新网格 ID 时停止闪烁。
科林
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
迟到总比不到好……
我使用
WM_SETREDRAW
。例如:
Better late than never...
I use
WM_SETREDRAW
. For example:是的,TStringgrid 中没有 BeginUpdate/EndUpdate,但每行或每列都有:
StringGrid1.Rows[0].BeginUpdate;
StringGrid1.Cols[0].BeginUpdate;
Yes, there is no BeginUpdate/EndUpdate in TStringgrid, but there is per row or per col:
StringGrid1.Rows[0].BeginUpdate;
StringGrid1.Cols[0].BeginUpdate;
These are methods of the `TStrings` object.
Use
StringGrid1.Rows[i]/Cols[i].BeginUpdate;
...
StringGrid1.Rows[i]/Cols[i].EndUpdate;
更新
您是否尝试设置
DoubleBuffered := true
?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
?您可以使用 Windows 函数 LockWindowUpdate(AHandle) 来阻止控件的刷新,然后使用 LockWindowUpdate(0) 来重新绘制它。
当句柄传递 Grid.Handle 时。
You can use the Windows function LockWindowUpdate(AHandle) to prevent the refresh of the control and then LockWindowUpdate(0) to repaint it.
As the handle pass the Grid.Handle.