Enabling mouse wheel zooming in a Microsoft Chart Control

后端 未结 2 1742
情书的邮戳
情书的邮戳 2020-12-20 17:24

how to enable zooming in Microsoft chart control by using Mouse wheel

I have the below code, i need to know how to make this event? in which class it is..

         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 18:19

    What you have is an handler method for the MouseWheel event. You need to attach your handler method to the MouseWheel event for the chart control. From the method signature, I assume that your chart control is named chData, so you could use the following code in your form's constructor:

    chData.MouseWheel += new EventHandler(chData_MouseWheel);
    

    Of course, you could also associate the handler with the event at design time. To do that, use the Properties Window and click the lightning bolt in the toolbar to switch to the "Events" view. Then find the MouseWheel event, click the drop-down arrow, and select your handler method's signature. This will cause the designer to write the above code into the code-behind file for your form.

    Aside from that, there's a giant red flag in your code: an empty catch block. If you aren't handling an exception or doing anything with it, then you should not be catching it. This isn't Pokemon, there's no reward for catching them all.

提交回复
热议问题