鼠标悬停在DataPoint上时更改MarkerImage并在离开Datapoint时更改回

时间:2019-04-06 13:04:29

标签: data-visualization vb.net-2010 mschart

我试图在用户将鼠标悬停在数据点上时更改绘制的数据点的标记图像。我在下面显示的代码:

数据点悬停在数据点上时一直在更改图像,但是没有将其更改回“ Red.png”吗?

有人能弄清楚为什么这种情况没有发生吗?

谢谢。

 Private Sub Chart1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Chart1.MouseMove
    Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)

    If result.ChartElementType = ChartElementType.DataPoint Then
        Chart1.Series(0).Points(result.PointIndex).MarkerImage = "Green.png"

    ElseIf result.ChartElementType = ChartElementType.PlottingArea Then
        Chart1.Series(0).MarkerImage = "Red.png"

    End If

End Sub

1 个答案:

答案 0 :(得分:0)

我发现: 更改这些行

ElseIf result.ChartElementType = ChartElementType.PlottingArea Then
        Chart1.Series(0).MarkerImage = "Red.png"

收件人

ElseIf result.ChartElementType = ChartElementType.PlottingArea Then
            For i = 0 To Chart1.Series(0).Points.Count - 1
                Chart1.Series(0).Points(i).MarkerImage = "Red.png"
            Next

工作过...