Skip to main content

Painting The Vertical Grid's Background

The ExpressVerticalGrid control provides several events allowing custom painting of the control’s elements (see the Custom Painting Overview topic for more information). The OnDrawBackground event occurs before painting the vertical grid’s background. Its parameters are listed below:

Parameter Description
ACanvas Specifies the surface of the control’s background being painted. This parameter provides access to various painting methods.
R Represents the background’s bounding rectangle.
AViewParams Represents an object containing view information about the painted area.
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 the default painting. In the latter case, the changes you make are discarded.

The following OnDrawBackground event handler fills the vertical grid control’s background with a bitmap:

procedure TStylesSimpleDemoMainForm.cxDBVerticalGridDrawBackground(
  Sender: TObject; ACanvas: TcxCanvas; const R: TRect;
  const AViewParams: TcxViewParams; var Done: Boolean);
var
  AImage: TBitmap;
begin
  AImage := TBitmap.Create;
  AImage.LoadFromFile('c:\images\blue.bmp');
  ACanvas.FillRect(R, AImage);
  Done := True;
  AImage.Free;
end;

The code’s result is shown in the following image: