Themed Grids in Delphi 2010

I was reminded of a new feature in Delphi 2010 when someone recently posted a new comment on a very old blog post. It was the post about my CodeCentral entry that provided a themed TDBGrid component.

In Delphi 2010 the TStringGrid, TDrawGrid and TDBGrid components now have a DrawingStyle property. The default value for this property is gdsThemed which means all grids in your Delphi 2010 applications will be themed by default. If you application isn’t themed, then your grids will use the gdsClassic style, which is how they appeared before Delphi 2010.

You actually get three different drawing style options. Themed, Classic and Gradient.

  • The Classic style is just the previous drawing style.
  • The Themed style uses the current theme information (if enabled) .
  • The Gradient style uses two new properties called GradientStartColor and GradientEndColor to paint the fixed row cells.

The following screen captures show each of the new styles.

Grids Classic Drawing Style

Grids Classic Drawing Style

Grids Themed Drawing Style

Grids Themed Drawing Style

Grids Gradient Drawing Style

Grids Gradient Drawing Style

Indicator Painting Issue

If you strain your eyes for long enough, you might see a painting issue with the Themed and Gradient drawing style images above. To be fair, I didn’t notice it until I wrote the sample application to demonstrate the feature. I had a look to see if the issue has been raised in QualityCentral yet and it hasn’t.

The issue is a lot more obvious when you change the gradient colors a little. As shown in the screen shot below.

Grids Gradient Drawing Style Issue

The indicator transparency issue

The indicator isn’t drawn as transparent. This is a simple fix and only occurs for the TDBGrid component since the indicator isn’t valid for the other grids. Internally the indicator image is stored in a TImageList. When the image from the image list is drawn it isn’t drawn with transparency.

The Fix

  1. Copy the DBGrids.pas file to your applications folder. It is located in the <InstallDir>\Source\Win32\DB folder.
  2. Search for FIndicators.Draw (There is only one occurrence in the entire unit located in the DrawCell method of TCustomDBGrid.)
  3. Change the line under the FIndicators.Draw line to the following:
(ARect.Top + ARect.Bottom - FIndicators.Height) shr 1, Indicator, dsTransparent, itImage, True);

The red bolded parameters are the additional parameters added to the Draw method call (which starts on the preceeding line).

The following screen shot was created with the above fix applied to the DBGrids unit.

Grids Gradient Drawing Style Issue Fixed

The indicator transparency issue fixed

It’s a shame the indicator is not actually exposed for easy customisation. Even more of a shame is the inability to customise the move column painting.

Source Code

The source code and a compiled executable is available for download.

Source Code Download


  1. I guess that this fix will be released only in D2011. You know Emb policy about bug fixes… A “complex” fix like that has to be fully tested! This single line change can potentially destroy one’s hard disk! 🙂

  2. Mauro says:

    there are other new bugs/Limits in Theme dbgrid on Delphi 2010

    for example ,

    if i active on the property option : dgTitleClick, the blue-Themed box on column header , is not more visible when mouse is over it

  3. Delphichem says:

    Great works like always.