Skip to main content

How to: Scroll a View Horizontally Using the Mouse Wheel

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