0
votes

I'm trying to override scroll functionality on DatagridView. (DGV with fixed RowCount which on scroll request refresh it self with new "scrolled" values instead of scrolling down to next values)

And I need to react myself to event and disable DatagridView to react to that event (disable it to scroll).

Something like:

protected override void OnScroll(ScrollEventArgs e)
{            
    ProcessScroll(e);

    //Distable DGV processing scroll request
    //base.OnScroll(e); 
}

However this event occurs after scrolling is done. And for instance FirstDisplayedScrollingRowIndex in this point have new value after scroll.

So please can does anyone know how to react to this event before it makes any changes, and disable it to make any changes ?

I cant just catch mouse wheel event, or detect presed key, because you can scroll through DatagridView while you selecting cell by mouse.

Thank you

1

1 Answers

0
votes

This is not tested, but how about storing the value of FirstDisplayedScrollingRowIndex and incase you want to "disable" the scroll, just assign it the previous value.

(source)

Edit: After testing it, this will make the gridview nto to scroll, but the scroll bars are still scrolling (with no affect). Which bring me to the next suggestion:
If you do not want to allow to scroll your grid view, simply remove the scroll bars...

this.gv.ScrollBars = ScrollBars.None;