Disable Mousewheel on WinForm in VB.NET 2005

How does one Disable the Mousewheel on a WinForm in VB.NET 2005?   I have a form with some text fields and a datagridview.  When the main form is active, I want to prevent the user from inadvertently scrolling to the next record. (i.e. force them to use the record navigation buttons.)  However, if the datagridview has the focus, I want the user to be able to scroll through the list.
KentDBerryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
You can do this in the control you don't want the Mousewheel  to work

    Private Sub TreeView1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseWheel
        Dim MW As HandledMouseEventArgs = e
        MW.Handled = True
    End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KentDBerryAuthor Commented:
My issue is that as soon as the form opens, or if the user finds a particular record, they can accidentally hit the scroll bar and the records scroll forward without the user realizing it.

Does this work on the navigator controls?  
0
Jorge PaulinoIT Pro/DeveloperCommented:
I never test it but I will try. Have you tried already ?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

KentDBerryAuthor Commented:
I'll be back in office on Monday, so I haven't tried as yet.
0
KentDBerryAuthor Commented:
JPaulino,

Weird.  My forms are not scrolling through records today as they were on Friday.  I'm new to WinForms. Do most forms as I describe default to not allowing the mousewheel to scroll through records on the main form?

And I verified there is a mousewheel event on the navigator control, so I'm sure your suggestion will work should I need to implement it.  Thank you for your help.

Kent
0
Jorge PaulinoIT Pro/DeveloperCommented:
I worka fine for me.

Glad I could help you and thanks for the grade!
0
Jorge PaulinoIT Pro/DeveloperCommented:
>> Do most forms as I describe default to not allowing the mousewheel to scroll through records on the main form?
Normally all the control allow (like datagridview, listview, listbox, etc) not the form.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.