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

# TCustomGrid.OnDrawCell

Event handler signalled to draw a cell in the grid control.

## Declaration

Source position: grids.pas line 1309

`protected property TCustomGrid.OnDrawCell : TOnDrawCell read FOnDrawCell write FOnDrawCell;`

## Description

OnDrawCell is a TOnDrawCell property with the event handler signalled to render a cell in the grid control. Parameters passed to the event handler identify the column and row numbers for the cell, the drawing rectangle, and the grid draw state for the cell.

OnDrawCell can be used to perform drawing operations which supplement or override the default drawing mechanism in the grid control. When DefaultDrawing property is True, the DefaultDrawCell method is called to render the cell background, state, text and focus in the default manner. Use OnDrawCell to perform drawing actions which differ from the default for the specified cell.

OnDrawCell can be used to render all aspects of a cell when DefaultDrawing is set to False. In this situation, the event handler must handle rendering the background, state, text, and focus for the cell.

OnDrawCell is signalled (when assigned) from the DrawCell method at run-time. It is not signalled at design-time. OnDrawCell occurs after the canvas has been configured using PrepareCanvas, and after DefaultDrawCell has been called (when DefaultDrawing is True).

## See also

TCustomGrid.PrepareCanvas |  | Prepares the canvas for drawing the cell at the specified location.
TCustomGrid.DefaultDrawing |  | Indicates if the default drawing mechanism is used to draw the background and text for cells.
TCustomGrid.DrawCell |  | Draws a cell using a given state at the specified grid location (Col, Row, rectangle).
TCustomGrid.DrawCellGrid |  | Draws cell grid lines for the control.
TOnDrawCell |  | Defines the event handler signalled to draw a cell on a grid control.