共用方式為


ChartSheetBase.SelectEvent Event

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

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

Syntax

'Declaration
Public Event SelectEvent As ChartEvents_SelectEventHandler
public 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.ChartSheetBase 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

ChartSheetBase Class

Microsoft.Office.Tools.Excel Namespace