这个示例展示了在运行时刻如何实现图表元素的自定义热跟踪和选择。

Note注意

要启用运行时刻热跟踪和选择,则应该把 ChartControl.RuntimeSelection 属性设置为 true

如果需要改变默认的热跟踪和选择,那么就接管 ChartControl.ObjectHotTrackedChartControl.ObjectSelected 事件,实现自定义热跟踪和选择方法,并把 Cancel 属性设置为 true

例如,下面的代码举例说明了如何禁用图表 图象 的热跟踪和选择。

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

private void chartControl1_ObjectHotTracked(object sender, HotTrackEventArgs e) {
   // Prevent the chart's diagram from being hot-tracked.
   if (e.Object is Diagram) 
      e.Cancel = true;
}

private void chartControl1_ObjectSelected(object sender, HotTrackEventArgs e) {
   // Prevent the chart's Diagram from being selected.
   if (e.Object is Diagram) 
      e.Cancel = true;
}
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraCharts
' ...

Private Sub OnObjectHotTracked(sender As Object, e As HotTrackEventArgs) _
Handles ChartControl1.ObjectHotTracked
   ' Prevent the chart's Diagram from being hot-tracked.
   If TypeOf e.Object Is Diagram Then
      e.Cancel = True
   End If
End Sub
 
Private Sub OnObjectSelected(sender As Object, e As HotTrackEventArgs) _
Handles ChartControl1.ObjectSelected
   ' Prevent the chart's Diagram from being selected.
   If TypeOf e.Object Is Diagram Then
      e.Cancel = True
   End If
End Sub

Expand image参阅