共用方式為


ChartSheet.SelectEvent 事件

會在選取 Microsoft.Office.Tools.Excel.ChartSheet 時發生。

命名空間:  Microsoft.Office.Tools.Excel
組件:   Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
Event SelectEvent As ChartEvents_SelectEventHandler
event ChartEvents_SelectEventHandler SelectEvent

範例

下列程式碼範例示範 SelectEvent 事件的處理常式,這個處理常式在選取目前 Microsoft.Office.Tools.Excel.ChartSheet 的主座標軸時會顯示訊息方塊。

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 安全性

請參閱

參考

ChartSheet 介面

Microsoft.Office.Tools.Excel 命名空間