You can modify the current selection at runtime by calling the methods of the NSelection object. The following code clears the selection and adds the first chart in the charts collection:
C# |
Copy Code
|
---|---|
chartControl.Controller.Selection.Clear(); chartControl.Controller.Selection.Add(chartControl.Charts[0]); |
Visual Basic |
Copy Code
|
---|---|
chartControl.Controller.Selection.Clear() chartControl.Controller.Selection.Add(chartControl.Charts(0)) |
Adding data points to the selection is slightly different:
C# |
Copy Code
|
---|---|
chartControl.Controller.Selection.AddDataPoint(someSeries, 1); |
Visual Basic |
Copy Code
|
---|---|
chartControl.Controller.Selection.AddDataPoint(someSeries, 1) |
You can also perform queries in the selection in order to check whether it contains objects from certain type. The following code will check whether the selection contains a chart:
C# |
Copy Code
|
---|---|
NSelection selection = chartControl.Controller.Selection; if (selection.ContainsObjectsOfType(typeof(NChart))) { ArrayList selectedChart = selection.GetSelectedObjectsOfType(typeof(NChart)); // do something with selected charts } |
Visual Basic |
Copy Code
|
---|---|
Dim selection As NSelection = chartControl.Controller.Selection If selection.ContainsObjectsOfType(GetType(NChart)) Then Dim selectedChart As ArrayList = selection.GetSelectedObjectsOfType(GetType(NChart)) ' do something with selected charts End If |