本示例展示了如何确定鼠标指针是否悬停在 轴标题 上,如果是,就在消息框中显示它的类型 (AxisTitleXAxisTitleY)。

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

private void chartControl1_ObjectHotTracked(object sender, HotTrackEventArgs e) {
    if (e.AdditionalObject is AxisTitle) {
        MessageBox.Show(e.AdditionalObject.GetType().ToString());
    }
}
Visual BasicCopyCode image复制代码
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Private Sub chartControl1_ObjectHotTracked(ByVal sender As Object, _ 
ByVal e As HotTrackEventArgs) Handles chartControl1.ObjectHotTracked
    If TypeOf e.AdditionalObject Is AxisTitle Then
        MessageBox.Show(e.AdditionalObject.GetType().ToString())
    End If
End Sub

在下面的插图中显示了结果。

CodeCentralShow Me

在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1727。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。

Expand image参阅