Share via


ChartSheet.SelectEvent Event

Occurs when the Microsoft.Office.Tools.Excel.ChartSheet is selected.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Event SelectEvent As ChartEvents_SelectEventHandler
event ChartEvents_SelectEventHandler SelectEvent

Examples

The following code example demonstrates a handler for the SelectEvent event that displays a message box when the primary axis of the current Microsoft.Office.Tools.Excel.ChartSheet is selected.

Private Sub DisplayPrimaryAxisSelections()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    Me.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    Me.ChartType = Excel.XlChartType.xl3DColumn
End Sub

Sub ChartSheet1_SelectEvent(ByVal ElementID As Integer, _
    ByVal Arg1 As Integer, ByVal Arg2 As Integer) _
    Handles Me.SelectEvent

    If Excel.XlChartItem.xlAxis = _
        CType(ElementID, Excel.XlChartItem) Then
        If Excel.XlAxisGroup.xlPrimary = _
            CType(Arg1, Excel.XlAxisGroup) Then
            MsgBox("The primary axis of the chart " & _
                "sheet was selected.")
        End If
    End If
End Sub
private void DisplayPrimaryAxisSelections()
{
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    this.ChartType = Excel.XlChartType.xl3DColumn;

    this.SelectEvent +=
        new Excel.ChartEvents_SelectEventHandler(
        ChartSheet1_SelectEvent);
}

void ChartSheet1_SelectEvent(int ElementID, int Arg1, int Arg2)
{
    if (Excel.XlChartItem.xlAxis == (Excel.XlChartItem)ElementID)
    {
        if (Excel.XlAxisGroup.xlPrimary == (Excel.XlAxisGroup)Arg1)
        {
            MessageBox.Show("The primary axis of the chart " +
                "sheet was selected.");
        }
    }
}

.NET Framework Security

See Also

Reference

ChartSheet Interface

Microsoft.Office.Tools.Excel Namespace