7

System.Windows.Forms.Form has only one scroll event-Scroll, but it is necessary to recognize scrolling up and scrolling down.Could you tell me,how to do this?

Ilya Blokh
  • 11,923
  • 11
  • 52
  • 84

3 Answers3

8

Use the passed System.Windows.Forms.ScrollEventArgs arguments' OldValue and NewValue properties to detect the scroll direction.

M.A. Hanin
  • 8,044
  • 33
  • 51
5
private void dgv_Scroll(object sender, ScrollEventArgs e)
        {
            if (e.OldValue > e.NewValue)
            {
                // here up
            }
            else
            {
                // here down
            }
        }
josliber
  • 43,891
  • 12
  • 98
  • 133
Mena Dawoud
  • 51
  • 1
  • 2
0

Checkout ScrollEventArgs Class and this answer.

Community
  • 1
  • 1
KMån
  • 9,896
  • 2
  • 31
  • 41