Eli Blokh
Eli Blokh

Reputation: 12293

How to detect : scrolling - up or down?

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?

Upvotes: 7

Views: 10171

Answers (3)

Mena Dawoud
Mena Dawoud

Reputation: 51

private void dgv_Scroll(object sender, ScrollEventArgs e)
        {
            if (e.OldValue > e.NewValue)
            {
                // here up
            }
            else
            {
                // here down
            }
        }

Upvotes: 5

Kamran Khan
Kamran Khan

Reputation: 9986

Checkout ScrollEventArgs Class and this answer.

Upvotes: 0

M.A. Hanin
M.A. Hanin

Reputation: 8074

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

Upvotes: 8

Related Questions