delphifiremonkeytstringgriddelphi-12-athens

How to increase column header height in StringGrid for Delphi FMX?


I have a simple TStringGrid on my form, but my column header height isn't large enough for the text to fit as can be seen here:

TStringGrid in Delphi IDE (Delphi Programming)

I'm simply trying to change the height of that column header, but I'm struggling to find the setting for it.


Someone asked this question before and the answer says to do the following:

StringGrid1.RowHeights[0] := 42;

But that doesn't work because RowHeights doesn't exist. I think this is because the question is for VCL and not FMX. So it works different in FMX.


I've looked through as many object inspector properties as I can, but I'm not finding one that seems to help me to increase the height of the column header.

Where can I find this? How do I change the column header height?

How do I do this? Ideally I'd like to do it via a design-time setting, but if it's not possible, then a run-time option is fine also.


Solution

  • I managed to find a way to change it programmatically during run-time:

    1. Add FMX.Header to your uses list.
    2. Add an OnApplyStyleLookup event to the TStringGrid component
    3. Use the following code with the OnApplyStyleLookup event:
    procedure TFrame_Windows11_SelectImage.StringGridApplyStyleLookup(Sender: TObject);
    begin
      var Header := THeader(TStringGrid(Sender).FindStyleResource('header'));
      if Assigned(Header) then
        Header.Height := 40; // Set your desired height here
    end;