51

There are lots of questions here about XE2 VCL Styles and custom colors for Buttons, Panels, edits, etc, and VCL Styles. As much as I wish the existing questions covered it, they don't... So DB Control Grids appear to be Yet Another Special Case.

  1. In the DB Control Grid VCL sources, it registers a style hook thusly: TCustomStyleEngine.RegisterStyleHook( TDBCtrlGrid, TScrollingStyleHook);

  2. However, that's not what you would descend from if you want to write your own DB Control Grid VCL style hook. If you do, you get the whole control painted like a very large scrollbar.

enter image description here

  1. So how do you custom-theme a DB Control grid? When you disable the themes completely, it seems to still not allow the active row to be custom painted. So I think that one must have to write a custom subclass and override the Paint method, plus write a VCL style hook class, for this purpose.

  2. It appears that one should probably mostly just customizing using the regular owner draw events OnPaintPanel, and that adding that event, if you didn't, fixes the biggest VCL Styles glitch that I see for TDBCtrlGrid, which is that it doesn't ever use the SelectedColor and just paints everything in flat gray or whatever else is the base color. If anyone can confirm that, or tell me otherwise, it would be appreciated.

2
  • 7
    If this isn't just a bug in XE2, then the logical place to look for a fix for this is the excellent VCL Styles Helpers by Rodrigo Ruz (RRUZ). code.google.com/p/vcl-styles-utils
    – Warren P
    Aug 27, 2014 at 13:39
  • 1
    Custom styling of a DB Control Grid remains an unsolved mystery in 2023. The DB Control Grid is in fact, a very crappy delphi 1 legacy control, and it's a good idea to simply REMOVE and replace by a custom control you wrote yourself, rather than trying to use the DB Control Grid.
    – Warren P
    Dec 4, 2023 at 20:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.