Compartir a través de


ChartSheetBase.ProtectContents (Propiedad)

Obtiene un valor que indica si está protegido el contenido del objeto Microsoft.Office.Tools.Excel.ChartSheetBase.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel.v4.0.Utilities (en Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Sintaxis

'Declaración
Public ReadOnly Property ProtectContents As Boolean
public bool ProtectContents { get; }

Valor de propiedad

Tipo: System.Boolean
true si el contenido del objeto Microsoft.Office.Tools.Excel.ChartSheetBase está protegido.

Comentarios

Así se protege todo el objeto Microsoft.Office.Tools.Excel.ChartSheetBase.

Ejemplos

El ejemplo de código siguiente utiliza el método Protect para proteger todo el contenido del objeto Microsoft.Office.Tools.Excel.ChartSheetBase actual.A continuación, el ejemplo usa la propiedad ProtectContents para comprobar que la hoja del gráfico está protegida y, a continuación, pregunta al usuario si desea quitar la protección de la hoja del gráfico utilizando el método 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(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();
        }
    }
}

Seguridad de .NET Framework

Vea también

Referencia

ChartSheetBase Clase

Microsoft.Office.Tools.Excel (Espacio de nombres)