Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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:

Delphi
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: