YOUSEFUL / DELPHI / COMPONENTS

TAtlasCellStyleEvent

Method type of TAtlasVirtualGrid.OnCellStyle: choose a cell's background and text colour.

Type Unit Atlas.VGrid · Product Atlas Virtual Grid

Description

TAtlasCellStyleEvent = procedure(Sender: TObject; Column: TAtlasGridColumn; DataRow: Integer; const Cell: TAtlasCell; var Background, TextColor: TColor) of object; Sender is the grid. Column is the grid column, so compare Column.DataIndex to find the data column. DataRow is the data row, not the row as shown. Background and TextColor arrive with the defaults; the selection colour is applied after the handler.

This type has no members of its own beyond those listed in its description.

Examples

Conditional colours

Assign with Grid.OnCellStyle := Styler.Style;.

pascal
uses Vcl.Graphics, Atlas.VGridData, Atlas.VGrid;

type
  TOrderStyler = class
    procedure Style(Sender: TObject; Column: TAtlasGridColumn; DataRow: Integer;
      const Cell: TAtlasCell; var Background, TextColor: TColor);
  end;

procedure TOrderStyler.Style(Sender: TObject; Column: TAtlasGridColumn; DataRow: Integer;
  const Cell: TAtlasCell; var Background, TextColor: TColor);
begin
  // Data column 3 is Paid: unpaid orders get a pale red cell.
  if (Column.DataIndex = 3) and not Cell.IsNull and (Cell.Number = 0) then Background := $00D8D8FF;
  // Data column 1 is Amount: 1,000 or more in dark green.
  if (Column.DataIndex = 1) and not Cell.IsNull and (Cell.Number >= 1000) then TextColor := $00207A20;
end;

TAtlasVirtualGrid · TAtlasGridColumn · TAtlasCell

Also in Atlas Virtual Grid

TAtlasVirtualGrid · TAtlasMemoryData · TAtlasVirtualData · TAtlasPlotData