Skip to main content

WebChartControl.ObjectSelected Event

Occurs when an end-user clicks on any chart element.

Namespace: DevExpress.XtraCharts.Web

Assembly: DevExpress.XtraCharts.v24.1.Web.dll

NuGet Package: DevExpress.Web.Visualization

Declaration

public event HotTrackEventHandler ObjectSelected

Event Data

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

Property Description
AdditionalObject Provides access to an object related to the object being hit. The returned value depends on the HotTrackEventArgs.Object type and hit point location.
Cancel Gets or sets whether the hot-tracking should be cancelled.
HitInfo Gets 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.
Object Gets the chart element, for which the event was raised.

Remarks

An end-user is able to hover any chart element by the mouse pointer and click on it. So, this chart element becomes selected, and the ObjectSelected event is generated. Handle this event if you want to perform some specific actions when an end-user selects a chart’s elements, or if you want to disable the selection of particular elements. Note that the currently selected element of the chart can be accessed via the WebChartControl.ObjectSelected property.

Note

This event won’t be fired, if it is processed on the client in the ASPxClientWebChartControl.ObjectSelected event handler, and the processOnServer property is set to false in that event handler.

Example

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

Note

To enable runtime hot-tracking and selection, set the WebChartControl.SelectionMode property to an appropriate value (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 illustrates how to disable selection and hot-tracking of a chart’s diagram.

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;
}
See Also