Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to prevent MouseWheel msgs from scrolling a DataGridView?

Status
Not open for further replies.

ProtocolPirate

Programmer
Nov 21, 2007
104
0
0
US
I want to control the scrolling directly from the MouseWheel handler because the automatic message translation converts one mousewheel click to three separate one line scroll messages. My VirtualMode DataGridView is overwhelmed by all the redrawing, scrolls slowly and getting a backlog in the message queue so that after you stop turning the wheel it keeps on scrolling for some time.

How can you shut off the scroll messages that are generated from the MouseWheel messages? I want to control the DGV's row directly from the MouseWheel handler.
 
I can't answer your question, but I can tell you that it is getting that information from the mouse settings in windows not something it is doing on it's own. I don't know that information will help your problem, but it may make you think of something.

As the little I know there isn't a way to tell actually how many notches/lines were scrolled because the drivers are automatically converting it base on the settings. You do it once and it sends through windows it actually moved the number specified. I could be wrong though as I've always worked with the default behavior because people are going to want that setting the way they want it. If that makes sense.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
I can't answer your question, but I can tell you that it is getting that information from the mouse settings in windows not something it is doing on it's own."

What information? I'm not looking for data values, I'm trying to prevent scrollbar messages from automatically being generated by MouseWheel messages.
 
What information? I'm not looking for data values, I'm trying to prevent scrollbar messages from automatically being generated by MouseWheel messages.
I guess I didn't explain that well enough. If you look in the mouse settings in the control panel there is an option to have it tell that 1 notch or line from the mouse is actually equal to more than 1. The value by default is usually 3. That is one reason why it hits it 3 times for each 1 time you notch the wheel. It doesn't send a value like go down three it pretends that the mouse wheel scrolled 3 times. It is possible you have some other problem as well, but that will generate a 3 for 1.

Like I said the one or two times I've captured the event for the wheel it wasn't to stop that behavior. I told you one of the places (actually the only place I know of) it will come from incase it might give you an idea or something to do a search for until someone else might help you if they can.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
If you don't want the mouse events to do anything then you need to TRAP the event.

Go to the event tab, you will have a ton of things you can extend/replace functionality for.

Find the one that sounds like it does what you need. Double click to send you to the event handler.
The event should have a sender and a "e"
if you don't want the event to do anything then you should be able to

Pub sub xxx_whateverEvent
e.handled
end sub

-Sometimes the answer to your question is the hack that works
 
There is no Handled member of the MouseEventArgs class. That is only present for Key events.
 
My database is down at the second, so i can't load a datagrid to test, but you will wind up with something like this:

Code:
Private Sub dgvTest_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) [b]Handles dgvTest.Scroll[/b]
        If sender.GetType.ToString = theMouseScrollwheel Then
            e.NewValue = e.OldValue
        End If
    End Sub

-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top