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?
 
Jorge PaulinoConnect With a Mentor IT 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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
All Courses

From novice to tech pro — start learning today.