Recommendations for the most useful Delphi TStringGrid (Grid) replacement
Asked Answered
A

6

13

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.

Aubert answered 28/6, 2011 at 6:56 Comment(3)
You can't really go wrong with the DevExpress suite. It takes a bit time to learn the mechanics of quantumgrid but the ROI is huge.Tameshatamez
Same opinion from me, DevExpress is very powerfull but takes a time to be managed. It is a mature product and printing is also possible with the printing-components.Misology
With Dev Express cxGrid, you can centralise the look and feel of your grids by using a single TcxStyleController. Saves a lot of effort.Prosser
C
13

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.

Cretan answered 28/6, 2011 at 13:30 Comment(2)
But beware - DevExpress are limiting their support to certain versions of Delphi. Can't remember exactly but there was a big outcry not long ago when they said they were going to drop support for Delphi 2010(!) - they eventually backtracked but I'm not sure about the level of support for D7 - if any.Lathe
I am not actively using DevExpress in any current projects, but in the projects I had used it in, I grew to know the code well enough to support it myself. I would caution developers to always be prepared to take over "support" themselves, or to have an exit strategy, and that applies to ANY third party control, not just developer express. And don't EVER add anything to your app that you don't have source code for.Cretan
M
7

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.

Mott answered 28/6, 2011 at 12:29 Comment(7)
Usually called "Virtual Treeview component".Cretan
+1 great component, especially if your handling large amounts of data.Presnell
It took a bit for me to the "virtual" idea worked into my thought process (the component doesn't (need to) own any data). It doesn't need to be so complicated though, if you already have all of your data stored in objects/variables.Mott
And ... That's what Virtual means. Your data is in your model (once) instead of cloned from your model to your TTreeNode objects. THus, it's harder for the two sets of objects to get out of sync, since the second of those two sets never existed in the first place. Non-virtual is what's complicated.Cretan
@boileau: What about print support for Virtual TreeView please?Aubert
I haven't seen any direct support for printing, I'm pretty sure you would have to do some sort of handling.Mott
When printing Virtual TreeViews, (a) you could do a cheap and dirty bitmap capture (which is cheap, dirty, and looks terrible), or (b) you could generate an HTML or RTF (rich text) equivalent and print that, or you could (c) use a banded reported system, and set up a similar set of columns. In the end (c) is almost always the best, because users almost always need to customize output, and some kind of runtime report options dialog is almost always needed.Cretan
M
4

I can strongly recommend to go with ExpressQuantumGrid!

You could think about a TStringGridToCxGrid facade class which replaces the TStringGrid and translates your legacy code to TcxGrid.

Manuelmanuela answered 28/6, 2011 at 10:49 Comment(7)
@Splash: How do I do that? Interesting.Aubert
I recommend you only use Express Quantum Grid if you need it's 300,000+ source code lines and 3,000 units worth of accompanying complexity. Sometimes, yes, it's what you need. But sometimes, it's too much, too heavyweight.Cretan
@Warren P: Agreed. Because of its power and flexibility TcxGrid is nontrivial and complex by nature. But this is basically also valid for TWoman. ;-)Manuelmanuela
At least you didn't say Irrational, like Pi.Cretan
@Brian Frost: You have to implement the same interface as TStringGrid publishes. Internally the properties and method calls must be mapped to appropriate TcxGrid members. A while ago I have written a static converter function which transforms our custom Grid to TcxGrid at runtime, but it should also be practiable as facade component.Manuelmanuela
@splash: careful now boy... :-) But at least you said complex and not complicated ;-DRunner
Isn't the mathematical definition of "complex", that it contains both "real and imaginary elements"?Cretan
R
4

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.

Replevin answered 28/6, 2011 at 13:29 Comment(1)
Nice. +1 for independant (starting from TCustomControl) implementation grid.Cretan
C
2

You might also want to consider BergSoft NextGrids http://www.bergsoft.net/

Costs pretty much nothing and has decent support

Creationism answered 28/6, 2011 at 9:35 Comment(3)
$59 USD is not "pretty much nothing". Call it Reasonable, affordable... Much less expensive than DevEx. True.Cretan
Good deal. :-) Nice looking stuff too.Cretan
I bought the BergSoft Suite some years ago for Delphi 7 - and never used it. Recently, I upgraded to the version for XE8 and they were most helpful. :)Cleghorn
M
1

You can try to use EhLib library, that is including TDBGridEh component. It's cheap and very powerful. http://www.ehlib.com

Mombasa answered 28/6, 2011 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.