mouse wheel events

Megalith

Well-known member
Joined
Aug 21, 2006
Messages
66
Programming Experience
10+
i have an issue RE: the mouse wheel event, my application needs to use the mouse wheel to change the row width on a datagridview control the method is nested inside the mousewheel event for the control and adjusts the width using the e.delta property the problem is is that the event isnt fired, ive tried reading the delta property from the mouse move property just to see if the delta property changes but it doesnt. Is this a known issue with .NET? perhaps my mouse is incompatible with this process :(
 
Mouse wheel isn't different from one process to the other, if it works at all in Windows it works everywhere. What do you mean by "mouse move property"? - that doesn't make sense, if you meant "mouse move event" then delta doesn't report to that event neither does wheel. Try this code and see if it outputs:
VB.NET:
Private Sub DataGridView1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles DataGridView1.MouseWheel
    Static counter As Integer
    counter += 1
    Me.Text = String.Format("event counter:{0} current delta:{1}", counter.ToString, e.Delta.ToString)
End Sub
 
hmmmmm well using your method above does indeed work but for some reason my method doesnt, maybe someone could shed some light on it :(

VB.NET:
 Private Sub DataGridView1_MouseWheel(ByVal sender As Object, _
                 ByVal e As System.Windows.Forms.MouseEventArgs) _
                 Handles DataGridView1.MouseWheel
        If e.Delta > 1 Then
            ' incease height
            MsgBox("Mouse Up")
        Else
            ' decrease height
            MsgBox("MouseOut")
        End If
    End Sub


ive simplified the code to just this and i get no msgbox's :(

i should point out that there are mouseclick, mousemove and mousedown methods used but these all work as intented.
 
I just tested both methods and, predictably, they both work as expected. The event is either raised or it's not. Changing the contents of the event handler doesn't change that. In this case the event IS raised. I tested it using a grid with text box columns and it worked whether the grid was in edit mode or not.
 
i will disable the other mouse events and reintroduce them 1 by 1. using this routine alone in a test app works fine. but for some reason in the application i am developing it wont, my only thought is another mouse event is overriding it but it should still fire shouldnt it? anyway will get back on this if i find the solution.
 
i rem'd out the other mouse events and wrote the mousewheel event again and it still wont find it. I dont know why it works in a new application but not in this one. i can live without the function the mousewheel would give and instead use a right click drag to achieve the same result (which i intended on doing in case the end user has a wheelless mouse) but would like to know why it wont work :( i can supply the whole code it is quite lengthy though so i wont paste it on the forum
 
Back
Top