Painting Row Values
The ExpressVerticalGrid control provides several events allowing custom painting of the control’s elements (see the Custom Painting Overview topic for more information). The OnDrawValue event occurs before painting the vertical grid’s row values. Its parameters are listed below:
Parameter | Description |
---|---|
ACanvas | Specifies the surface of the row value being painted. This parameter provides access to various painting methods. |
APainter | Represents the painter object used for default painting. You can use the interface provided by the object to paint the header using the current style settings. |
AValueInfo | Specifies the object providing view information about the row cell value being painted. |
Done | 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 are discarded. |
The following code shows the OnDrawValue event handler drawing the HP row values over 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.FillRect(AValueInfo.BoundsRect);
ACanvas.Font.Color := clRed;
AValueInfo.Transparent := True;
end;
end;
The code’s result is shown in the following image: