Im FNCDataGrid Cell-Farbe ändern

Mittwoch, 11. Dezember 2024
10:30

Guten Tag TMS-Team,
wie kann in einem TMSFNCDataGrid eine Zeile in Abhängigkeit eines Wertes geändert werden?
Beispiel:
If Wert = 0 then
Begin
Row.Color := clRed;
Oder auch den Wert in einer anderen Formatierung wie zum Beispiel:
Font.Color := Red;
Font.Style := [fsBold];
End;

Ich habe verschiedenes ausprobiert, fand aber weder in OnGetCellDisplayValue noch in
OnGetCellLayout eine Lösung.
In der Dokumentation zu dem TMSFNCDataGrid fand ich auch keinen Beitrag.

Mit freundlichem Gruß
Hans-Peter Bongers

You can do this in the OnGetCellLayout

procedure TForm5.TMSFNCDataGrid1GetCellLayout(Sender: TObject;
  ACell: TTMSFNCDataGridCell);
var
  Value: Integer;
begin
  if (ACell.Row > 0) and (ACell.Column = 0) then
  begin
    if TryStrToInt(ACell.Data.Value.AsString, Value) then
    begin
      if Odd(Value) then
      begin
        ACell.Layout.Fill.Color := gcRed;
        ACell.Layout.Font.Color := gcWhite;
        ACell.Layout.Font.Style := [TFontStyle.fsBold];
      end;
    end;
  end;
end;