打印 TDBGrid
如何在不安装或下载组件的情况下打印 DBGrid?
或者
如何将 DBGrid 的数据放入 RichEdit 中,以便我可以从那里打印它?
How can I print a DBGrid without installing or downloading components?
OR
How can I get a DBGrid's data into a RichEdit so that I can print it from there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
数据感知控件从 DataSource 属性获取数据,并使用它。不过,您必须手动遍历它,不可能立即完成(没有第三方库/组件)。
Data aware controls get their data from DataSource property, use that. You have to manually traverse it though, no instant way possible (without third party libraries / components).
您需要能够为每个字段计算出适当的打印宽度,大致如下:
然后循环遍历所有记录,并循环遍历每个字段进行打印。
您需要添加一些代码来处理分页符。
You will need to be able to work out an appropriate print width for each field, something along these lines:
Then loop through all the records, and loop through each field to print.
You'll need to add some code to handle page breaks.
您可以循环进入网格并手动将其全部放入您的 Richedit 中。
但为什么要重新发明轮子呢?只需使用报告组件即可。
在 delphi 7 - delphi2010 上,您已经安装了 rave 组件。
You can loop into your grid and put it all into your richedit manually.
But why reinvent the wheel. Just use a report component.
On delphi 7 - delphi2010 you have the rave components installed.