FMXGrid Header

I know I'm being stupid, but I can't work out how to use the Header in TTMSFMXGrid.

I can easily set it visible, but I don't see how to put a title on it.

I found the GetHeader method, which returns a TControl.

So I tried :

MyLabel := TLabel.Create(self);
MyLabel.Parent := MyGrid.GetHeader;
MyLabel.Align := Client;
MyLabel.Text := 'Test';

Nothing is shown in the header area. Maybe my brains not in gear today !!

Any help ?

You can simply set the grid header cell text with:


TMSFMXGrid1.Cells[1,0] := 'header cell text';
Hi Bruno

I think you misunderstood me.

Your example sets the contents of the "fixed" and "normal" cells.

I have a grid with a fixed row at the top containing column headings, and normal rows below that.

Row 0 is the fixed "column heading" row.

When I get Grid.Options.Header.Visible to true, a large header area is shown above row 0. Similarly if I set Grid.Options.Footer.Visible a large footer area is shown below the table.

I want to place contents (text at the moment) within those areas, but cannot see how to do it.

This code works fine here:

procedure TForm1.Button1Click(Sender: TObject);
var
  lbl: TLabel;
  hdr: TControl;

begin
  hdr:= TMSFMXGrid1.GetHeader;
  lbl:= TLabel.Create(hdr);
  lbl.Parent := hdr;
  lbl.Text := 'Hello world';
end;

Thanks for your quick reply

You're right!

I was doing exactly the same thing, but in the forms OnCreate event.

At what point should I create my label, is there a suitable event ?

The OnApplyStyleLookup event is the event triggered when the control got actually fully created by the FireMonkey framework.

thanks.