下面的示例展示了如何接管 ChartControl.MouseMove 事件,并计算鼠标指针当前悬停的点的点击信息。 然后,在窗体的标题中显示位于鼠标指针下面的图表元素的名称。

C#CopyCode image复制代码
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

private void chartControl1_MouseMove(object sender, MouseEventArgs e) {
    ChartHitInfo hi = chartControl1.CalcHitInfo(new System.Drawing.Point(e.X, e.Y));
    this.Text = hi.HitTest.ToString();
}
Visual BasicCopyCode image复制代码
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Private Sub ChartControl1_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs) _
Handles ChartControl1.MouseMove
    Dim hi As ChartHitInfo = ChartControl1.CalcHitInfo(New System.Drawing.Point(e.X, e.Y))
    Me.Text = hi.HitTest.ToString()
End Sub

Expand image参阅