ChartControl.SetObjectSelection(Object) Method

Selects the specified chart element at runtime.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.UI.dll

Declaration

public void SetObjectSelection(
    object obj
)
Public Sub SetObjectSelection(
    obj As Object
)

Parameters

Name Type Description
obj Object

A Object which specifies the chart element to select.

Remarks

Use the SetObjectSelection method to implement custom selection of chart elements at runtime. To clear the selection of any chart element, the ChartControl.ClearSelection method should be used.

NOTE

To enable standard selection of chart elements by end-users at runtime, set the ChartControl.RuntimeSelection property to true.

Examples

This example demonstrates how to select a specific object (diagram, axis, series point, etc.) in a Windows Forms chart.

To do this, it is necessary to call the ChartControl.SetObjectSelection method with an object to select as its parameter, and then call the ChartControl.Refresh method.

using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace SetSelection {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void btnDiagram_Click(object sender, EventArgs e) {
            // Select a diagram.
            chartControl1.SetObjectSelection(chartControl1.Diagram);
        }

        private void btnAxis_Click(object sender, EventArgs e) {
            // Select an axis.
            chartControl1.SetObjectSelection(((XYDiagram)chartControl1.Diagram).AxisX);
        }

        private void btnSeriesPoint_Click(object sender, EventArgs e) {
            // Select a series point.
            SeriesPoint pointToSelect = this.chartControl1.Series[0].Points[1] as SeriesPoint;
            if (pointToSelect != null) {
                this.chartControl1.SetObjectSelection(pointToSelect);
            }
        }
    }
}
See Also