Skip to main content

BaseView.MouseWheel Event

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

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

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

Declaration

[DXCategory("Mouse")]
public event MouseEventHandler MouseWheel

Event Data

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

Property Description
Button Gets which mouse button was pressed.
Clicks Gets the number of times the mouse button was pressed and released.
Delta Gets 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.
Location Gets the location of the mouse during the generating mouse event.
X Gets the x-coordinate of the mouse during the generating mouse event.
Y Gets 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.

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;
}
See Also