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

# TCustomGrid.MouseDown

Handles mouse down events for the grid control.

## Declaration

Source position: grids.pas line 1152

`protected procedure TCustomGrid.MouseDown(`
`Button: TMouseButton;`
`Shift: TShiftState;`
`X: Integer;`
`Y: Integer`
`); override;`

## Arguments

`Button` |  | Mouse button for the event.
`Shift` |  | Shift state for the event.
`X` |  | Horizontal coordinate for the mouse event.
`Y` |  | Vertical coordinate for the mouse event.

## Description

MouseDown is overridden in TCustomGrid to ensure that cached grid information in GCache is updated for mouse down events, and both GridState and GridFlags are updated for the control.

MouseDown calls the inherited method to handle focus changes for the control and drag operations. The OnMouseDown event handler is signalled (when assigned) by the ancestor.

No additional actions are performed in the method at design-time, when the mouse Button is not allowed in the grid control, or when the control cannot receive focus.

MouseDown ensures that the grid control is focused when visible and enabled, and does not contain csNoFocus in the ControlStyle flags. MouseDown updates GCache with the coordinates for the mouse down event. The grid "hot" zone in the cached information determines the value assigned to GridState, GridFlags, CursorState and the actions performed for the mouse event.

gzFixedCells

Sets GridState to gsColSizing when both goColSizing and goFixedColSizing have been included in the Options and the cursor state is gcsColWidthChanging.

Otherwise, GridState is set to gsHeaderClicking. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzFixedCols

GridState is set to gsColSizing when goColSizing has been included in the Options and the cursor state is gcsColWidthChanging.

Otherwise, GridState is set to gsColMoving. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzFixedRows

GridState is set to gsRowMoving when goRowSizing is included in Options and CursorState is gcsRowHeightChanging.

Otherwise, GridState is set to gsRowMoving. The cell is drawn using the "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.

gzNormal

When the mouse down event is over a button-style cell, it is drawn in the "pushed" state. No additional actions are needed for the event.

Other cells use the values in Options and CursorState to determine whether the mouse event is for column sizing, selection, or enabling/disabling the cell editor. GridState is updated to the corresponding value.

## See also

TControl.MouseDown |  | Handles a mouse down event for the control.