Back to Devexpress

BaseView.MouseDown Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-e1bff468.md

latest9.5 KB
Original Source

BaseView.MouseDown Event

Occurs when the mouse pointer is over a View and a mouse button is pressed.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Mouse")]
public event MouseEventHandler MouseDown
vb
<DXCategory("Mouse")>
Public Event MouseDown As MouseEventHandler

Event Data

The MouseDown event's data class is MouseEventArgs. The following properties provide information specific to this event:

PropertyDescription
ButtonGets which mouse button was pressed.
ClicksGets the number of times the mouse button was pressed and released.
DeltaGets a signed count of the number of detents the mouse wheel has rotated, multiplied by the WHEEL_DELTA constant. A detent is one notch of the mouse wheel.
LocationGets the location of the mouse during the generating mouse event.
XGets the x-coordinate of the mouse during the generating mouse event.
YGets the y-coordinate of the mouse during the generating mouse event.

Remarks

If you handle the MouseDown event for a detail View, the event sender identifies the clone that has actually raised the event.

A common practice of handling the MouseDown event is to perform specific actions in response to pressing a specific View element. Refer to the Hit Information help topic for information on how to identify the element located under the mouse pointer.

csharp
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;

private void gridView1_MouseDown(object sender, MouseEventArgs e) {
    GridHitInfo info = (sender as GridView).CalcHitInfo(e.Location);
    int rowHandle = info.InRow ? info.RowHandle : GridControl.InvalidRowHandle;
    MessageBox.Show(rowHandle.ToString());
}
vb
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo

Private Sub gridView1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles gridView1.MouseDown
    Dim info As GridHitInfo = (TryCast(sender, GridView)).CalcHitInfo(e.Location)
    Dim rowHandle As Integer = If(info.InRow, info.RowHandle, GridControl.InvalidRowHandle)
    MessageBox.Show(rowHandle.ToString())
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the MouseDown event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-multi-cell-editing/CS/MultiSelectionEditingHelper.cs#L25

csharp
this.view.CellValueChanged += view_CellValueChanged;
    this.view.MouseDown += view_MouseDown;
}

winforms-grid-enable-editing-in-group-row-to-change-cell-values/CS/WindowsApplication3/GroupEditProvider.cs#L74

csharp
view.CustomDrawGroupRow += OnCustomDrawGroupRow;
view.MouseDown += OnMouseDown;
view.MouseMove += OnMouseMove;

xaf-how-to-show-a-hyper-link-url-email-etc-for-a-business-class-property/CS/HyperLinkPropertyEditor.Win/GridListEditorOpenHyperLinkViewController.cs#L17

csharp
if(gridListEditor != null && gridListEditor.GridView != null) {
    gridListEditor.GridView.MouseDown += GridView_MouseDown;
}

winforms-grid-rename-grid-filters-save-restore-layout/CS/WindowsApplication3/FilterNameProvider.cs#L54

csharp
void SubscribeToEvents() {
    view.MouseDown += OnViewMouseDown;
    view.CustomFilterDisplayText += OnViewCustomFilterDisplayText;

winforms-grid-add-check-box-to-column-header/CS/GridViewColumnHeaderExtender.cs#L255

csharp
view.CustomDrawColumnHeader -= OnCustomDrawColumnHeader;
view.MouseDown -= OnMouseDown;
view.MouseUp -= OnMouseUp;

winforms-grid-multi-cell-editing/VB/MultiSelectionEditingHelper.vb#L24

vb
AddHandler Me.view.CellValueChanged, AddressOf view_CellValueChanged
    AddHandler Me.view.MouseDown, AddressOf view_MouseDown
End Sub

winforms-grid-enable-editing-in-group-row-to-change-cell-values/VB/WindowsApplication3/GroupEditProvider.vb#L77

vb
AddHandler view.CustomDrawGroupRow, AddressOf OnCustomDrawGroupRow
AddHandler view.MouseDown, AddressOf OnMouseDown
AddHandler view.MouseMove, AddressOf OnMouseMove

xaf-how-to-show-a-hyper-link-url-email-etc-for-a-business-class-property/VB/HyperLinkPropertyEditor.Win/GridListEditorOpenHyperLinkViewController.vb#L19

vb
If gridListEditor IsNot Nothing AndAlso gridListEditor.GridView IsNot Nothing Then
    AddHandler gridListEditor.GridView.MouseDown, AddressOf GridView_MouseDown
End If

winforms-grid-rename-grid-filters-save-restore-layout/VB/WindowsApplication3/FilterNameProvider.vb#L66

vb
Private Sub SubscribeToEvents()
    AddHandler view.MouseDown, AddressOf OnViewMouseDown
    AddHandler view.CustomFilterDisplayText, AddressOf OnViewCustomFilterDisplayText

winforms-grid-add-check-box-to-column-header/VB/GridViewColumnHeaderExtender.vb#L235

vb
RemoveHandler _view.CustomDrawColumnHeader, AddressOf OnCustomDrawColumnHeader
RemoveHandler _view.MouseDown, AddressOf OnMouseDown
RemoveHandler _view.MouseUp, AddressOf OnMouseUp

See Also

Click

MouseMove

MouseUp

BandedGridView.CalcHitInfo*

CardView.CalcHitInfo*

GridView.CalcHitInfo*

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace