Index Property Example

This event procedure runs whenever the user clicks inside the chart workspace. If the user clicks a point, the procedure displays the series and point index values. Note that the event procedure in this example is declared as required by Visual Basic. For more information about using event procedures, see Declaring and Using Event Procedures in VBScript.

Private Sub ChartSpace1_Click(ByVal ChartEventInfo As OWC.WCChartEventInfo)
    Set c = ChartSpace1.Constants
    If ChartSpace1.SelectionType = c.chSelectionPoint Then
        seriesNumber = ChartSpace1.Selection.Parent.Index
        pointNumber = ChartSpace1.Selection.Index
        MsgBox "series " & seriesNumber & " point " & pointNumber
    End If
End Sub

This example moves series 1 to the fourth index position of an XY chart containing 6 series. During the move, series 2 through 4 are reordered to series 1 through 3. Series 0 and series 5 stay in the same position.

ChartSpace1.Charts(0).SeriesCollection(1).Index = 4