最有用的 Delphi TStringGrid (Grid) 替代品推荐
Delphi 的薄弱领域之一是网格(例如 TStringGrid),尽管它的基本工作做得很好,但当您需要打印它或自定义其外观时,它会变得更加困难。我已经使用它大约 15 年了,因此它很好地嵌入到我的应用程序中,随着时间的推移,我已经自行开发了 TGrid 到 RTF 转换(用于通过 MSWord 打印)的解决方案,并使用 TDrawGrid 进行更多定制。我的解决方案(仍然)必须在 Delphi 7 和 Delphi XE 中工作。碰巧的是,我的网格都不是数据库绑定的,它们都是用代码填充的单元格。
现在,我计划整理我的报告并“美化”我的表单,这意味着用更强大的实现替换网格。那里有很多负载,我有两个 Developer Express Quantum Grid 和TMS 网格包。尽管尝试字体、颜色和打印的时间非常有限,但我希望能就我应该采用的众多网格/打印显示报告组合中的哪一个提出建议。我目前没有报告生成器,正在考虑使用 FastReports,但我愿意接受建议。
One of the weaker areas of Delphi are the grids (eg TStringGrid) where, although it does a good basic job, it becomes harder when you need to print it or customise its appearance. I've used it for about 15 years thus its pretty embedded within my apps and over time I've home-rolled solutions for TGrid-to-RTF conversion (for printing via MSWord) and used TDrawGrid for a bit more customisation. My solutions (still) have to work in both Delphi 7 and Delphi XE. As it happens, none of my grids are DB-bound, they are all cell-populated in code.
Now I'm planning to sort out my reporting and 'pretty-up' my forms which means replacing the grid with a more capable implementation. There are loads out there and I've got two of them Developer Express Quantum Grid and the TMS Grid Pack. Time is very limited though to experiement with fonts, colours and printing and I would appreciate recommendations for which of the many grid / print-display report combinations I should adopt. I presenty do not have a report generator and was considering FastReports but I'm open to suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
大约在 1998 年,我厌倦了 TStringGrid,开始了漫长的向外之旅。我大量使用虚拟网格视图控件,包括 Roman Mochalev 的 ExGridView(移植到 Delphi 2010/XE 此处)和Developer Express 的量子网格控制及其附带的打印套件,以及 Mike Lischke 的虚拟树视图。是的。这是树视图。但如果您不创建多个级别的节点,它也会形成一个非常好的虚拟网格。
最后,这些都不是完美的。您的应用程序的要求可能包括:
打印。如果是这样,我会选择 Developer Express 组件,因为它们的网格组件和其他组件在其打印套件中内置了打印支持。
大量定制绘画,但没有印刷。如果是这样,我会回到 VCL TDrawGrid,因为否则更复杂的库存绘画系统只会妨碍您。
保持简单。如果是这样,我推荐 ExGridView 组件。其他解决方案似乎都让我完成了 98% 的任务,并且需要大量维护来解决自定义绘画故障、打印故障或其他问题。如果您想要的只是一个看起来像 Windows 2000 时代的虚拟网格来显示模型中的数据,请使用 ExGridView。
将来可能需要嵌套节点(树的东西)。然后现在就从 VirtualTreeView 开始,暂时将其用作网格,稍后无缝添加树功能。
在您的情况下,可能还有更多的“附加要求”,超出了我在这里所能想到和列出的范围。但正是这些“也”的事情将(或应该)决定你的选择。您的应用程序必须 24/7/365.25 运行吗?好吧,那就保持简单,避免花哨的东西,这些东西以后会伤害你。
既然您声明您需要打印、漂亮的主题绘画,并且您已经拥有 Developer Express 组件,那么这将是#1 最合乎逻辑的选择。它是一个稳定、成熟、高质量的组件套件。对于稍后查看这个问题的其他人,我唯一的警告是,这是一个复杂的、重量级的解决方案,并不适合 100% 的“只需要一个比 TStringGrid 更好的可用网格”的所有 Delphi 应用程序。 DevEx Quantum Grid 可以复制您在 Outlook 中见过的几乎所有网格功能,例如,包括“分组依据”功能。
In about 1998 I got tired of TStringGrid and began a long journey outwards. I have used virtual grid view controls heavily, including Roman Mochalev's ExGridView (ported to Delphi 2010/XE here) and developer express's quantum grid control, and the printing suite that goes with it, as well as Virtual Tree View by Mike Lischke. Yes. It's a tree view. But if you don't create multiple levels of nodes, it makes a pretty great virtual grid too.
In the end, none of these are perfect. Your application's requirements may include:
Printing. If so, I would go towards the Developer Express components since their grid component, and other components, have printing support built into in their printing suite.
A lot of custom painting, but no printing. If so, I would go back to the VCL TDrawGrid, because otherwise more complex stock painting systems are just going to get in your way.
Keeping it simple. If so, I recommend the ExGridView component. The other solutions all seem to get me 98% of the way there, and require a tonne of maintenance to solve custom painting glitches, printing glitches, or whatever else. If all you want is a Windows 2000 era looking virtual grid showing data from your model, use ExGridView.
Could need to nest nodes (tree stuff) in the future. Then just start with VirtualTreeView now, and use it as a grid for now, and seamlessly add tree functionality later.
There are many more "additional requirements" that are possible in your case, than I can possibly think of and list here. But it's these "also" things that will (or should) dictate your choice. Your application has to run 24/7/365.25? Well, then keep it simple, and avoid fancy stuff that will hurt you later.
Since you state you need printing, nice looking themed painting, and you already own the Developer Express components, that would be the #1 most logical choice. It is a stable, mature, and high-quality component suite. For other people who view this question later, my only caveat is that it's a complex, heavy-weight solution, and not right for 100% of all Delphi apps that "just need a workable grid better than TStringGrid". DevEx Quantum Grid can copy just about every grid feature you have ever seen in Outlook, for example, including "group by" functionality.
虚拟树视图组件可能是一种可能性。我们在应用程序中将其用作网格。我还没有尝试过打印,但我会在不久的将来的某个时候尝试。它可以导出为富文本或 HTML,这对此很有用。
编辑:顺便说一下,它是开源的并且非常完善。
EDIT2:更正了组件的名称。我最初是这么做的,但当我建立链接时它就丢失了。
The Virtual Treeview component might be a possibility. We use it as a grid in our application. I haven't tried printing, but I will at some point in the near future. It can export to rich text or html, which could be useful for that.
EDIT: It's open source and quite polished, by the way.
EDIT2: Corrected the name of the component. I had done this originally, but it got lost when I made the link.
我强烈推荐使用 ExpressQuantumGrid!
您可以考虑使用
TStringGridToCxGrid
外观类来替换TStringGrid
并将旧代码转换为TcxGrid
。I can strongly recommend to go with ExpressQuantumGrid!
You could think about a
TStringGridToCxGrid
facade class which replaces theTStringGrid
and translates your legacy code toTcxGrid
.我一直对 KGrid 很感兴趣。然而,除了一些简单的测试之外,我还没有使用过它。如果您对免费替代方案感兴趣,那么值得一试。
I've always been intrigued by the KGrid. I have not used it beyond some simple testing however. It's worth checking out if you're interested in a free alternative.
您可能还想考虑 BergSoft NextGrids http://www.bergsoft.net/
成本几乎为零,并且具有体面的支持
You might also want to consider BergSoft NextGrids http://www.bergsoft.net/
Costs pretty much nothing and has decent support
您可以尝试使用EhLib库,即包含TDBGridEh组件。它很便宜而且非常强大。 http://www.ehlib.com
You can try to use EhLib library, that is including TDBGridEh component. It's cheap and very powerful. http://www.ehlib.com