Proprietà ChartSheet.ProtectContents

Ottiene un valore che indica se il contenuto dell'oggetto Microsoft.Office.Tools.Excel.ChartSheet è protetto.

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

Sintassi

'Dichiarazione
ReadOnly Property ProtectContents As Boolean
    Get
bool ProtectContents { get; }

Valore proprietà

Tipo: System.Boolean
true se il contenuto dell'oggetto Microsoft.Office.Tools.Excel.ChartSheet è protetto.

Note

Questa impostazione consente di proteggere l'intero oggetto Microsoft.Office.Tools.Excel.ChartSheet.

Esempi

Nell'esempio di codice riportato di seguito viene utilizzato il metodo Protect per proteggere tutto il contenuto dell'oggetto Microsoft.Office.Tools.Excel.ChartSheet corrente. Nell'esempio viene utilizzata la proprietà ProtectContents per verificare che il foglio grafico sia protetto, quindi viene chiesto all'utente di rimuovere la protezione dal foglio grafico utilizzando il metodo Unprotect.

Private Sub ChartSheetProtection()
    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

    Me.Protect(DrawingObjects:=True, Contents:=True, _
        Scenarios:=True, UserInterfaceOnly:=False)

    If Me.ProtectContents Then
        If DialogResult.Yes = MessageBox.Show("The chart sheet" & _
            " is protected. Unprotect the chart sheet?", _
            "Example", MessageBoxButtons.YesNo) Then
            Me.Unprotect()
        End If
    End If
End Sub
private void ChartSheetProtection()
{
    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.Protect(missing, true, true, true, false);

    if (this.ProtectContents)
    {
        if (DialogResult.Yes ==
            MessageBox.Show("The chart sheet is protected. " +
            "Unprotect the chart sheet?", "Example", 
            MessageBoxButtons.YesNo))
        {
            this.Unprotect(missing);
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ChartSheet Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Excel