Back to Devexpress

ChartControl.ObjectHotTracked Event

windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-6df0f308.md

latest9.2 KB
Original Source

ChartControl.ObjectHotTracked Event

Occurs before any chart element is hot-tracked at runtime.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public event HotTrackEventHandler ObjectHotTracked
vb
Public Event ObjectHotTracked As HotTrackEventHandler

Event Data

The ObjectHotTracked event's data class is HotTrackEventArgs. The following properties provide information specific to this event:

PropertyDescription
AdditionalObjectProvides access to an object related to the object being hit. The returned value depends on the HotTrackEventArgs.Object type and hit point location.
CancelGets or sets whether the hot-tracking should be cancelled.
HitInfoGets details on the chart elements located at the point where an end-user has clicked when hot-tracking or selecting a chart element at runtime.
ObjectGets the chart element, for which the event was raised.

Remarks

If the ChartControl.RuntimeHitTesting property is set to true , end-users will be able to hot-track chart elements.

Handle the ObjectHotTracked event if you want to perform specific actions when an end-user hot-tracks a chart’s elements, or if you want to disable the hot-tracking of particular elements. Note that the currently hot-tracked element of the chart can be accessed via the HotTrackEventArgs.Object property.

Note

If you handle the ObjectHotTracked event, it will be raised and information on hit-testing will be collected, regardless of the current ChartControl.RuntimeHitTesting property value.

Examples

Interactive Points

This example allows a user to edit (move) series point data at runtime.

View Example

Custom Hot-tracking and Selection

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the ObjectHotTracked event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-custom-items/CS/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.cs#L23

csharp
chart.SeriesSelectionMode = SeriesSelectionMode.Point;
chart.ObjectHotTracked += Chart_ObjectHotTracked;
chart.MouseDoubleClick += MouseDoubleClick;

winforms-chart-draw-a-custom-legend-marker-for-a-series-point/CS/CustomSeriesPointDrawingSample/Form1.cs#L43

csharp
chart.BoundDataChanged += OnBoundDataChanged;
chart.ObjectHotTracked += OnObjectHotTracked;

winforms-chart-draw-a-custom-legend-marker-for-a-series/CS/CustomDrawingSample/Form1.cs#L54

csharp
chart.CustomDrawSeries += OnCustomDrawSeries;
    chart.ObjectHotTracked += OnObjectHotTracked;
}

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.cs#L23

csharp
chart.SeriesSelectionMode = SeriesSelectionMode.Point;
chart.ObjectHotTracked += Chart_ObjectHotTracked;
chart.ObjectSelected += Chart_ObjectSelected;

winforms-dashboard-custom-items/VB/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.vb#L29

vb
chart.SeriesSelectionMode = SeriesSelectionMode.Point
AddHandler chart.ObjectHotTracked, AddressOf Chart_ObjectHotTracked
AddHandler chart.MouseDoubleClick, AddressOf MouseDoubleClick

winforms-chart-draw-a-custom-legend-marker-for-a-series-point/VB/CustomSeriesPointDrawingSample/Form1.vb#L48

vb
AddHandler Me.chart.BoundDataChanged, AddressOf Me.OnBoundDataChanged
AddHandler Me.chart.ObjectHotTracked, AddressOf Me.OnObjectHotTracked
Using context = New CustomSeriesPointDrawingSample.Model.NwindDbContext()

winforms-chart-draw-a-custom-legend-marker-for-a-series/VB/CustomDrawingSample/Form1.vb#L58

vb
AddHandler chart.CustomDrawSeries, AddressOf OnCustomDrawSeries
    AddHandler chart.ObjectHotTracked, AddressOf OnObjectHotTracked
End Sub

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.vb#L29

vb
chart.SeriesSelectionMode = SeriesSelectionMode.Point
AddHandler chart.ObjectHotTracked, AddressOf Chart_ObjectHotTracked
AddHandler chart.ObjectSelected, AddressOf Chart_ObjectSelected

See Also

ObjectSelected

ChartControl Class

ChartControl Members

DevExpress.XtraCharts Namespace