Skip to main content

TcxCustomVerticalGrid.OnDrawValue Event

Occurs before painting row cell values.

Declaration

property OnDrawValue: TcxVerticalGridDrawValueEvent read; write;

Remarks

The OnDrawValue event is fired when grid row cell values need repainting.

The Sender parameter specifies the vertical grid to which the row belongs.

The ACanvas parameter specifies the surface being painted.

The APainter parameter provides access to the painter object used for default painting. You can use the interface provided by the object to paint the cell value using the current style settings.

The AValueInfo parameter returns ViewInfo information required to render the current cell value.

The Done parameter specifies whether the default painting routines should be suppressed. Set the parameter to True, to cancel default painting; set it to False, to allow default painting. In the latter case, the changes you make will be discarded.

The following code shows an OnDrawValue event handler that displays HP row values greater than 300 in red:

procedure TStylesSimpleDemoMainForm.cxDBVerticalGridDrawValue(
  Sender: TObject; ACanvas: TcxCanvas; APainter: TcxvgPainter;
  AValueInfo: TcxRowValueInfo; var Done: Boolean);
begin
  if (TcxEditorRow(AValueInfo.Row).Properties.Caption = 'HP') and (cxDBVerticalGridHP.Properties.Values[AValueInfo.RecordIndex] > 300) then
  begin
    ACanvas.Brush.Color := AValueInfo.ViewParams.Color;
    ACanvas.FillRect(AValueInfo.VisibleRect);
    ACanvas.Font.Color := clRed;
    ACanvas.Font.Style := [fsBold];
    ACanvas.DrawText(TcxCustomTextEditViewInfo(AValueInfo.EditViewInfo).Text, AValueInfo.BoundsRect, 0);
    Done := True;
  end;
end;

See Also