Library Vcl NextSuite 6 NextGrid6 Reference Classes TNxGridView6 OnGetCellColor

OnGetCellColor

Occurs on Cell's background being painted.

pas
property OnGetCellColor: TNxGetCellColorEvent read FOnGetCellColor write FOnGetCellColor;

  • Parameter CellColor in the event can be set in order to change Color of Cell's background dynamically depending on Cell's value for example.
  • State parameter is used to determine cells status such as cell being selected.

Example

pas
procedure TForm1.NxReportGridView61GetCellColor(Sender: TObject; ACol, ARow: Integer;
  var CellColor: TColor; State: TNxCellDrawState);
begin
  if not (csSelected in State) then
  begin
    if ARow = -1 then CellColor := clCream; // insert row

    if ARow mod 2 = 0 then CellColor := clMoneyGreen; // color every next row

  end;
end;

Remarks

CellColor parameter is initially set by grid using Color properties of Cell and/or Column. "Empty" cells that are visible on screen, but have index higher than RowCount get color from a column.

Sign in