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

# TCustomDrawGrid.ToggleCheckbox

Toggles the state for a check box cell between the checked and unchecked values.

## Declaration

Source position: grids.pas line 1441

`protected procedure TCustomDrawGrid.ToggleCheckbox; virtual;`

## Description

ToggleCheckbox is a method used to toggle the state for a check box located in the cell at Col and Row in the grid control.

No actions are performed in the method when Col is not an editable column in the grid. This can occur when goEditing has not been included in the Options for the control. It can also occur if the column definition in Columns has its ReadOnly property set to True.

ToggleCheckbox determines the TCheckboxState value for the cell. The default state is cbGrayed. GetCheckboxState is called to get the current state using the OnGetCheckboxState event handler (when assigned). The value is toggled (cbChecked becomes cbUnchecked, and vice versa). SetCheckboxState is called to apply the toggled value using the OnSetCheckboxState event handler (when assigned), and to redraw the cell.

The OnCheckboxToggled event handler is signalled (when assigned) prior to exiting from the method.

ToggleCheckbox is called from the CellClick method when a left mouse button click occurs in the cell. It is also called from the KeyDown method when the Space (VK_SPACE) key is applied for the cell.

## See also

TCustomGrid.OnCheckboxToggled |  | Event handler signalled when the value for a check box cell is toggled.