Share via


ChartSheet.SelectEvent Event

Definition

Occurs when the ChartSheet is selected.

public:
 event Microsoft::Office::Interop::Excel::ChartEvents_SelectEventHandler ^ SelectEvent;
event Microsoft.Office.Interop.Excel.ChartEvents_SelectEventHandler SelectEvent;
member this.SelectEvent : Microsoft.Office.Interop.Excel.ChartEvents_SelectEventHandler 
Event SelectEvent As ChartEvents_SelectEventHandler 

Event Type

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

Applies to