Search code examples
c#c#-4.0mschartmicrosoft-chart-controls

Mouse wheel rolled event for MS chart control


Im trying to figure out how to zoom in and out of a MS chart by rolling the mouse back and forth. Ive had a look in the charts event list but cant find anything which would be suitable.

Is this possible + whats the best way to go about doing this?


Solution

  • As I mentioned in a comment above, in my code the Charts are dynamically created at design time, but I see there is indeed a MouseWheel event: AddHandler newChart.MouseWheel, AddressOf Chart_MouseWheel, this should be usable for you:

    The function signature is as follows:

    Public Sub Chart_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    
    End Sub
    

    You'll want to use the e.Delta property to understand how many detentes the Wheel has moved.

    HTH