Compartir a través de


ChartSheet.ProtectContents Property

Definition

Gets a value that indicates whether the contents of the ChartSheet are protected.

public:
 property bool ProtectContents { bool get(); };
public bool ProtectContents { get; }
member this.ProtectContents : bool
Public ReadOnly Property ProtectContents As Boolean

Property Value

true if the contents of the ChartSheet are protected.

Examples

The following code example uses the Protect method to protect all contents of the current Microsoft.Office.Tools.Excel.ChartSheet. The example then uses the ProtectContents property to verify that the chart sheet is protected, and then prompts the user to remove protection from the chart sheet by using the Unprotect method.

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();
        }
    }
}
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

Remarks

This protects the entire Microsoft.Office.Tools.Excel.ChartSheet.

Applies to