Condividi tramite


Evento Chart.BeforeDoubleClick (System 2007)

Aggiornamento: novembre 2007

Si verifica quando si fa doppio clic sul controllo Chart, prima dell'azione di doppio clic predefinita.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Sintassi

Public Event BeforeDoubleClick As ChartEvents_BeforeDoubleClickEventHandler

Dim instance As Chart
Dim handler As ChartEvents_BeforeDoubleClickEventHandler

AddHandler instance.BeforeDoubleClick, handler
public event ChartEvents_BeforeDoubleClickEventHandler BeforeDoubleClick

Note

Questo evento non si verifica con il metodo DoubleClick.

Esempi

Nell'esempio di codice riportato di seguito viene creato un controllo Chart con un gestore per l'evento BeforeDoubleClick che visualizza una finestra di messaggio quando si fa doppio clic su un asse del grafico. Nell'esempio viene inoltre impostato su true il parametro Cancel del gestore eventi affinché il grafico non riceva l'azione di doppio clic quando l'utente fa doppio clic su un asse.

WithEvents DoubleClickChart As Microsoft.Office.Tools.Excel.Chart

Private Sub DisallowDoubleClicksOnAxis()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    DoubleClickChart = Me.Controls.AddChart(Me.Range("D2", "H12"), _
        "DoubleClickChart")
    DoubleClickChart.SetSourceData(Me.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    DoubleClickChart.ChartType = Excel.XlChartType.xl3DColumn
End Sub

Sub DoubleClickChart_BeforeDoubleClick(ByVal ElementID As Integer, _
    ByVal Arg1 As Integer, ByVal Arg2 As Integer, _
    ByRef Cancel As Boolean) Handles DoubleClickChart.BeforeDoubleClick

    If ElementID = Fix(Excel.XlChartItem.xlAxis) Then
        MsgBox("Formatting this axis is not allowed.")
        Cancel = True
    End If
End Sub
private void DisallowDoubleClicksOnAxis()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");
    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.BeforeDoubleClick +=
        new Excel.ChartEvents_BeforeDoubleClickEventHandler(
        chart1_BeforeDoubleClick);
}

void chart1_BeforeDoubleClick(int ElementID, int Arg1, 
    int Arg2, ref bool Cancel)
{
    if (ElementID == (int)Excel.XlChartItem.xlAxis)
    {
        MessageBox.Show("Formatting this axis is not allowed.");
        Cancel = true;
    }
}

Autorizzazioni

Vedere anche

Riferimenti

Chart Classe

Membri Chart

Spazio dei nomi Microsoft.Office.Tools.Excel