FMX. When having banding enabled, and setting the individual cell color within a column, the normal cells are colored but the cells in the banded rows do not change in color and remain in the banded color. This works properly in FNC Grid, but not in the DataGrid.
I've tried a lot and can only come to the conclusion that this is a bug. Moreover, unfortunately I also seem to have to set the font color as well as the grid-color. They both should technically not be altered when I'm only changing the cell's fill color.
This is how to reproduce: Have several columns, enable banding and run the following:
for Arow := 1 to TMSFNCDataGrid.RowCount-1 do begin
TMSFNCDataGrid.Layouts[1,Arow].Fill.Color := claRed
TMSFNCDataGrid.Layouts[1,Arow].Font.Color := claWhite;
TMSFNCDataGrid.Layouts[1,Arow].Stroke.Color := claGray;
end;
The app is in dark-mode, using the default Nero theme. However this problem also occurs when I have a light theme installed. Running Delphi 12.2, and having latest version of FNC UI Pack installed (v4.2.0.4).
Certain properties of the Layout do not have priority over global cell appearance. The font does. If you want that the cell layout has priority you can use the following code via the OnGetCellLayoutHasPriority:
procedure TForm1.TMSFNCDataGrid1GetCellLayoutHasPriority(Sender: TObject;
ACell: TTMSFNCDataGridCellCoord; var AHasPriority: Boolean);
begin
AHasPriority := True;
end;
You can also dynamically determine priority for example, the layout has priority except when the cell is selected:
procedure TForm1.TMSFNCDataGrid1GetCellLayoutHasPriority(Sender: TObject;
ACell: TTMSFNCDataGridCellCoord; var AHasPriority: Boolean);
begin
AHasPriority := not TMSFNCDataGrid1.IsCellSelected(ACell);
end;
As soon as the Layouts property is used, that Layout will be chosen for the cell, including all properties even though you technically only set the fill color. You can always override this in the OnGetCellLayout event.
Thank you for your reply and help, and awesome - I can work with that.
Another, perhaps similar situation is the following where your suggestion unfortunately doesn't work. Somewhere else in my code, on another DataGrid I'm doing:
for aRow := 1 to TMSFNCDataGrid.RowCount-1 do begin
if MyCondition=True then begin
for Acol := 0 to TMSFNCDataGrid.ColumnCount-1 do begin
TMSFNCDataGrid.FontColors[Acol,Arow] := claGray;
end
end
else begin
if SomOtherCondition=true then begin
for Acol := 0 to TMSFNCDataGrid.ColumnCount-1 do begin
TMSFNCDataGrid.FontColors[Acol,Arow] := claLightBlue;
end;
end;
end;
end;
With AHasPriority=true the background of the rows are now all, in my case due to the Style, white. Banding gone.
For now my only solution to this seems to be having to turn banding off.
Thank you for the feedback. The Layout takes priority on all settings. Including fill & stroke. We'll write it down and see if we can specify priority for certain properties.