Skip to main content

ChartControl.SetObjectSelection(Object) Method

Selects the specified chart element at runtime.

Namespace: DevExpress.XtraCharts

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

NuGet Package: DevExpress.Win.Charts

Declaration

public void SetObjectSelection(
    object obj
)

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.

Example

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);
            }
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetObjectSelection(Object) method.

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.

See Also