Back to Devexpress

BaseView.MouseWheel Event

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

latest4.6 KB
Original Source

BaseView.MouseWheel Event

Occurs when the mouse wheel is moved while a View has focus.

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 MouseWheel
vb
<DXCategory("Mouse")>
Public Event MouseWheel As MouseEventHandler

Event Data

The MouseWheel 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

Handle the MouseWheel event to perform specific actions when moving the mouse wheel. By default, the View scrolls through rows/cards when performing mouse wheel scrolling.

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

Example

The following example handles the BaseView.MouseWheel event to perform horizontal scrolling, instead of vertical scrolling, when the mouse wheel is rotated. The View is horizontally scrolled by changing the GridView.LeftCoord property value.

To prevent the default vertical scrolling action, the event handler sets the Handled parameter to true.

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

private void gridView1_MouseWheel(object sender, MouseEventArgs e) {
    GridView view = (sender as GridView);
    view.LeftCoord += e.Delta;
    (e as DXMouseEventArgs).Handled = true;
}
vb
Imports DevExpress.Utils
Imports DevExpress.XtraGrid.Views.Grid

Private Sub GridView1_MouseWheel(sender As Object, e As MouseEventArgs) Handles GridView1.MouseWheel
    Dim view As GridView = CType(sender, GridView)
    view.LeftCoord += e.Delta
    DirectCast(e, DXMouseEventArgs).Handled = True
End Sub

See Also

MouseDown

MouseMove

MouseUp

Click

BandedGridView.CalcHitInfo*

CardView.CalcHitInfo*

GridView.CalcHitInfo*

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace