TFNCDataGrid formatting

I succeeded in setting the first row up as headers for the columns and set the font to bold by using grid.fonts.style.
However, when I do sorting by clicking in the header, the headers font is no longer bold.
Do I have to reset all formatting properties?

Additionally I failed setting the background color of the headers cells. How can I do this?

Thanks a lot!

Can you share you code?

layoutdemo.zip (66.4 KB)

This is to test basic layout options and styles. Run the program an d klick ob button btnStyle. Now the headder of theb grid is bold. as soon as you click on a header to sort this columns, bold is gone.

BTW: How can I make the header of the columns colored?

When tied to a dataset, the cells are reloaded. Since the data is virtual, so is the styling. You will need to change the style globally:

  aGrid.CellAppearance.FixedLayout.Font.Style := [TFontStyle.fsBold];
  aGrid.CellAppearance.FixedLayout.Fill.Color := gcOrangered;

Thank you for the prompt response.

I understand, that formatting is lost, wenn data is reloaded. So do I have to set my grids formats every time, when sorting, filtering (what else?) occurs?

Additionally: I wanted to format the header of the columns only. So setting the global font won´t help, will it?`

And: I failed to set the background color of the columns header - how can I do this?

BTW: TTMSFNCDataGrid is awesome, I like it very much. I came from DevEx products and their grid is very good, but FNCDataGrid outperforms :- )

Global properties at grid level will persist and apply. cell settings will not be persisted. You can use events to override this as well OnGetCellLayout for example.

Thanks for the kind words :ok_hand:

The above code also demonstrates this.

aGrid.CellAppearance.FixedLayout.Fill.Color := gcOrangered;

aGrid.CellAppearance allows you to customize layouts for all cell states (fixed, selected, focused, ...)

Ah! I uderstand - the magic word is FixedLayout - so this apllies to fixed cells only.

Hmm. But I want to set the color for the headers of the column only, no fixed footer, no fixed columns, just the header aka column titles.

Then you can implement the OnGetCellLayout event:

procedure TForm1.TMSFNCDataGrid1GetCellLayout(Sender: TObject;
  ACell: TTMSFNCDataGridCell);
begin
  if ACell.Row = 0 then
  begin
    ACell.Layout.Fill.Color := gcRed;
  end;
end;

I know. My point ist, that I want all my grids share a common layout. I want to pack this in some procedures/classes, I can call when needed. Setting events is a bit cumbersome and bears the danger of overwriting them later.

Thanks for investigating.

The thing is, when applying properties to cells, most likely you want it tied to specific data, when sorting however (and connected to a dataset), the data could change, meaning the first cell might contain different information, then setting a specific cell property such as font color or layout will not move along with the cell. If you want to give full control to the grid you could choose

TMSFNCDataGridDatabaseAdapter1.LoadMode := almAllRecords;

When then sorts inside the grid instead of a dataset level.

We'll investigate however if we can find a workaround preserving specific cell settings.

Yeah, basically you are right. It makes no sense to pre-set formatting for cells, that change later.

But in my case, I am speaking of non-changing cells, headers, footers. For them it would be a benefit to set their apperance in advance and - using methods or procedures - for all grids in my project, so they all look the same.

Anyway - thanks a lot!