views:

188

answers:

2

I'm working on converting the codebase of an "open-source" project to something that will actually work. I put the term in quotes because what the original authors did was take a commercial product and say "OK, we've made enough money off this now. Here's the source code. Do whatever you'd like to with it." Unfortunately, the codebase as-is requires over $1000 of proprietary component libraries to compile.

I've carefully worked most of the proprietary stuff out, except for one major exception. It uses the InfoPower TwwDBGrid quite a bit. In one important place, it has a grid that displays a name column and several checkboxes, and both the background color and the text color of the name column can be customized for each individual record.

I've got the code to do this in the Infopower grid, and it would be trivial to reimplement for a DevEx grid, but I just can't seem to find an open-source grid that can handle it. I don't need the full power of the InfoPower grid, but I do need a DB grid that will let you specify column types, such as a checkbox column, and that has an event handler for coloring cells at draw-time.

Does anyone know of a grid that meets these requirements? I'd really prefer not to have to do something ugly, like hacking it with a TdbCtrlGrid, if I can avoid it...

+6  A: 

The regular TDBGrid can be adapted to display a checkbox and can color its cells. It can also handle custom controls to some degree, and is generally a lot more customizable than most people give it credit for. Unless you have requirements not already specified here, I haven't seen anything which rules it out.

Craig Stuntz
Ooo... very nice article! I didn't know that TDBGrid could do that. But I just did a very simple test program involving a TClientDataset with a single TBooleanField and a TDBGrid, and the grid doesn't give me a checkbox, it gives a text field that will only accept "True" and "False". If there's some way to get it to display a TDBCheckbox instead, I'd really love to know about it! (I'm on D2010, in case that helps.)
Mason Wheeler
I think I was remembering that incorrectly, but a little Googling turned up this: http://delphi.about.com/od/delphitips2009/qt/dbgrid-checkbox.htm I'll update may answer.
Craig Stuntz
Thanks, that works.
Mason Wheeler
+3  A: 

The questions is answered, but look at SMDBGrid, it's free and meet your requirements, it will save your time instead of reimplement them.

alt text

Mohammed Nasman
That looks very nice! And you're right, it'll save a lot of time over trying to implement this behavior manually. I'm changing the accepted answer to this one. Thanks for bringing it to my attention. :)
Mason Wheeler