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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any way to cancel a panels mousewheel event?

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
here is my code

Private Sub pnlGlGrid_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlGlGrid.MouseWheel
If Me.blnGlCodeScroll = True Then
'cancel scroll
End If

End Sub

what i want to do is if blnGlCodeScroll = true i dont want the user to be able to scroll the panel with the mousewheel. With keydown you can set e.handled to true and it will cancel it but there doesnt seem to be anything like that for the mousewheel.
 
Try setting e.Delta to 0.

This should set the number of clicks detected to nothing and therefore be equivalent to handling the event.

Craig
 
I couldnt do that, it said e.delta is read only. What i have decided to do is override the panels onmousewheel event but im still stuck.

Here is what i have so far.

Public Class GlCodeDataGridNoScrollPanel
Inherits System.Windows.Forms.Panel

#Region " Windows Form Designer generated code "



Private blnCodeScroll As Boolean
Public Property Scroll()
Get
Return blnCodeScroll
End Get
Set(ByVal Value)
blnCodeScroll = Value
End Set
End Property


Protected Overrides Sub OnMouseWheel(ByVal e As System.Windows.Forms.MouseEventArgs)

If blnCodeScroll = True Then Exit Sub

'What code is needed here to scroll like normal?

End Sub


End Class


What do i need to do to make it scroll if blnCodeScroll = false?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top