2

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?

Hans Rudel
  • 3,433
  • 5
  • 39
  • 62
  • 1
    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` , seems like that should work for you. – Chris Zeh Oct 29 '12 at 15:46
  • You are right. I had just seen the general mousewheel event. Thanks for pointing out my mistake. If u post that as an answer i'll make this closed. Thanks :) – Hans Rudel Oct 29 '12 at 15:51

1 Answers1

1

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

Chris Zeh
  • 924
  • 8
  • 23
  • No problem Hans, good luck! You might even consider adding keyboard modifiers to your MouseWheel Zooming. So something like if you hold the `ALT+MouseWheel` you will scroll Up/Down, and `CTRL+MouseWheel` you scroll Left/Right. Would be nice for quick plot navigation :-) – Chris Zeh Oct 29 '12 at 16:24