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

# TCustomDBGrid.MouseDown

Handles mouse down messages in the control and signals the OnMouseDown event handler.

## Declaration

Source position: dbgrids.pas line 494

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

## Arguments

`Button` |  | Mouse button examined in the method.
`Shift` |  | Shift / Ctrl / Alt modifier for the mouse button.
`X` |  | Horizontal coordinate for the mouse button click.
`Y` |  | Vertical coordinate for the mouse button click.

## Description

MouseDown handles mouse button clicks (when allowed) in the control. MouseDown ensures that the specified Button and State are correctly applied to the control similar to the processing provided in KeyDown method. MouseDown translates screen coordinates into the row and column numbers used in the control and performs actions needed for focus selection, editing or navigation.

No actions are performed in the method at design-time, when GridStatus contains gsUpdatingData, or when the specified Button is not allowed by the grid Options or the linked dataset state.

If the control is not already focused, SetFocus is called. MouseDown signals the OnMouseDown event handler when assigned in the class instance.

Left Mouse Button (or any mouse button when dgAnyButtonCanSelect is in Options)
  Clears the row Selection if already selected in the grid.
Right Mouse Button
  Toggles the selected row in the control, or opens the PopupMenu when assigned.
Ctrl + Left Mouse Button
  Toggles the row in the current SelectedRows.