Tuesday, October 13, 2009

Adding an OnMouseWheelScrolled to DevExpress AgDataGrid

Just a quick note on adding an event triggered when you scroll the AgDataGrid using the Mouse Wheel.

In the DataGrid.cs file add an event...

public event EventHandler OnMouseWheelScrolled;

then in the DoVerticalScrollChange method add (my code in Bold)...

protected virtual void DoVerticalScrollChange(object sender, MouseWheelHandlerEventArgs args) {
if(!IsMouseInControl) return;
if(Parent == null) return;
if(VerticalScrollBar != null) {
VerticalScrollBar.Value -= args.Delta;
if (OnMouseWheelScrolled != null)
OnMouseWheelScrolled(sender, args);
PerformLayout();
}
}

Now I am able to hide a popup when the user scrolls the grid.

No comments: