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?
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?
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.
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.
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
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.