[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Grids' (#lcl)

# TCustomGrid.OnPrepareCanvas

Event handler signalled to prepare the Canvas to draw the grid.

## Declaration

Source position: grids.pas line 1308

`protected property TCustomGrid.OnPrepareCanvas : TOnPrepareCanvasEvent read FOnPrepareCanvas write FOnPrepareCanvas;`

## Description

OnPrepareCanvas is a TOnPrepareCanvasEvent property with the event handler signalled to configure the control Canvas to draw a cell at specified coordinates using a specific state. OnPrepareCanvas is signalled (when assigned) from the DoPrepareCanvas method.

OnPrepareCanvas allows the Pen, Brush, Font, and Color defaults assigned in PrepareCanvas to be overridden for a specified column and row to use a specific TGridDrawState value. It offers the last chance to change the appearance of a cell before it is drawn in the DrawCell or ShowCellHintWindow methods.

Use OnDrawCell (implemented in the TCustomDrawGrid descendant) to override the actions performed in the DefaultDrawCell method when DefaultDrawing is enabled.

## See also

TCustomGrid.PrepareCanvas |  | Prepares the canvas for drawing the cell at the specified location.
TCustomGrid.ShowCellHintWindow |  | Gets and displays the cell hint(s) for the current cell in the grid.
TCustomGrid.DrawCell |  | Draws a cell using a given state at the specified grid location (Col, Row, rectangle).
TCustomDrawGrid.OnDrawCell |  | Event handler signalled to draw a cell in the grid control.
TOnPrepareCanvasEvent |  | Specifies an event handler signalled when preparing the canvas for a grid control.
TGridDrawState |  | Enumeration with Grid draw state values.