Back to Devexpress

How to: Implement Custom Hot-Tracking and Selection

windowsforms-2510-controls-and-libraries-chart-control-examples-end-user-interaction-how-to-implement-custom-hot-tracking-and-selection.md

latest2.6 KB
Original Source

How to: Implement Custom Hot-Tracking and Selection

  • Nov 13, 2018
  • 2 minutes to read

This example demonstrates how to implement custom hot-tracking and selection of the chart’s elements at runtime.

Note

To enable runtime selection, the ChartControl.SelectionMode property should be set to Single , Multiple or Extended.

If you want to change the default hot-tracking and selection, you should handle the ChartControl.ObjectHotTracked and ChartControl.ObjectSelected events, implement your custom hot-tracking and selection approaches and set the Cancel property to true.

For example, the code below disables selection and hot-tracking of a chart’s diagram.

csharp
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;
}
vb
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

See Also

How to: Show Series Labels Only for Hot-tracked Points

How to: Determine which Series Point Is Under the Test Point

How to: Determine a Chart Element the Mouse Pointer Hovers Over