Skip to content
The Road to Delphi — Delphi, VCL, VCL Styles, UxTheme and WinAPI

Using custom colors in the TDBGrid columns with vcl styles enabled

, ,

The TDBGrid component allows you to customize the colors of the columns and fonts used to draw the data.

Unfortunately if you uses the vcl styles all these customizations are lost

This issue is caused because the TCustomDBGrid.DrawCell method ignores the custom colors of the columns when the vcl styles are enabled. So the solution is patch this method to allow use the proper colors. After of this you will get a result like so.

I just uploaded this patch as part of the vcl styles utils project. To use it you must add the Vcl.Styles.DbGrid unit to the uses part of your form after of the Vcl.DBGrids unit.

6 responses

  1. Some of those grids look way cool.

  2. Eduardo Avatar
    Eduardo

    Rodrigo great job!!

  3. Nice hint

  4. Peter Helfrich Avatar
    Peter Helfrich

    Hello,
    I get error messages:

    unit Vcl.Styles.DbGrid;

    function TDbGridHelper.GetIndicators: TImageList;
    begin
    Result:=Self.FIndicators;
    end;

    message:

    [dcc32 Fehler] Vcl.Styles.DbGrid.pas(70): E2361 Auf private-Symbol TCustomDBGrid.FIndicators kann nicht zugegriffen werden

    What can I do?

    Best regards,
    Peter

    1. Hello Peter, I just added a fix for this (https://github.com/RRUZ/vcl-styles-utils), try updating your local copy of the project .

  5. Peter Helfrich Avatar
    Peter Helfrich

    Hello Rodrigo,

    thank you very much. It works fine now.

    Best regards.

Leave a Reply

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading