我如何知道 Delphi TDBGrid 何时完成从数据库的填充?
我有一个在 Delphi 2007 Pro 中填充 TDBGrid 的数据库。当网格填充完成后,我想根据网格处理的数据自动填充列表框。我可以通过观察并等待网格完全填充数据集然后调用下一个过程来手动执行此操作。当网格完成自动填充时,是否有一个事件允许调用下一个过程?谢谢。
I have a database populating a TDBGrid in Delphi 2007 Pro. When the grid finishes populating, I want to automatically fill a list box based on data processed from the grid. I can do this manually by watching and waiting for the grid to completely fill with the dataset and then calling my next procedure. Is there an event that would allow calling the next procedure when the grid finishes populating automatically? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用的是
TDataSet
后代,则可以使用其AfterOpen
事件:“在数据集建立对其数据的访问权限并将数据集置于 dsBrowse 状态后调用 AfterOpen。”< /code>
编辑(Duilio 的回答):在下面,“CDS”是一个“TClientDataSet”。 “TDBGrid”也通过“TDataSource”附加到数据集,但是网格的功能不会以任何方式受到下面的代码的影响,或者列表框的功能与网格的功能无关。
If you're using a
TDataSet
descendant, you can use itsAfterOpen
event:"AfterOpen is called after the dataset establishes access to its data and the dataset is put into dsBrowse state."
edit (code sample for comments for Duilio's answer): In the below, 'CDS' is a 'TClientDataSet'. A 'TDBGrid' is also attached to the data set by means of a 'TDataSource', but the grid's functionality is not in any way effected by the code below, or the ListBox's functionality with the grid's for that matter..
我认为你可以执行:
这将从你的表中获取所有数据。完成后,您的 DBGrid 应该已填充。
I think you could execute:
This will get all the data from your table. When done, your DBGrid should be populated.