如何使游标线跟随鼠标在图表中使用C# [英] how to make the cursor lines to follow the mouse in charts using C#
问题描述
>
图片下面显示了我的项目中的图表。正如你可以看到有两个虚线交叉线。我被要求让它跟随鼠标,但现在只有当我点击它移动的图表。我试图使用CursorPositionChanging但它没有工作。
CursorEventHandler也未显示在以下命令中:
The picture below shows a chart in my project. As you can see there are two dotted crossing lines. I’m asked to make it to follow the mouse, but now only if I click on the chart it moves. I tried to use CursorPositionChanging but it didn’t work. CursorEventHandler also is not shown in the command below:
this.chart1.CursorPositionChanging += new System.Windows.Forms.DataVisualization.Charting.Chart.CursorEventHandler(this.chart1_CursorPositionChanging);
我们需要添加额外的lib吗?
现在我有两个问题:
1.使行跟随鼠标
2.缺少CursorEventHandler
do we need to add extra lib for that? So I have two problems now: 1. Make the lines to follow the mouse 2. Missing CursorEventHandler
窗体应用程序与C#
推荐答案
图表支持一个'MouseMove'事件, 。 MouseEventArgs包含鼠标的位置,因此每次事件触发时,可以根据该数据移动虚线。
The chart supports a 'MouseMove' event which is fired each time the mouse is moved inside the chart. The MouseEventArgs contain the position of the mouse so u can move the dotted lines based on that data each time the event fires.
这篇关于如何使游标线跟随鼠标在图表中使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!