WorksheetBase.ProtectDrawingObjects Propriedade

Definição

Obtém um valor que indica se as formas estão protegidas.Gets a value that indicates whether shapes are protected.

public bool ProtectDrawingObjects { get; }

Valor da propriedade

Boolean

true se as formas estiverem protegidas; caso contrário, false.true if shapes are protected; otherwise, false.

Exemplos

O exemplo de código a seguir obtém o valor da ProtectDrawingObjects propriedade para determinar se as formas na planilha estão protegidas.The following code example gets the value of the ProtectDrawingObjects property to determine whether shapes on the worksheet are protected. Se as formas estiverem desprotegidas, o Protect método será chamado com o DrawingObjects parâmetro definido como para true que as formas sejam protegidas.If shapes are unprotected, then the Protect method is called with the DrawingObjects parameter set to true so that shapes are protected.

Este exemplo destina-se a uma personalização no nível de documento.This example is for a document-level customization.

private void ProtectShapes()
{
    if (!this.ProtectDrawingObjects)
    {
        if (DialogResult.Yes == MessageBox.Show("Shapes in this worksheet " +
            "are not protected. Protect shapes the worksheet?", "Example", 
            MessageBoxButtons.YesNo))
        {
            // Protect shapes, but do not change any 
            // other protection type.
            this.Protect(true, this.ProtectContents, 
                this.ProtectScenarios, this.ProtectionMode,
                this.Protection.AllowFormattingCells,
                this.Protection.AllowFormattingColumns,
                this.Protection.AllowFormattingRows,
                this.Protection.AllowInsertingColumns,
                this.Protection.AllowInsertingRows,
                this.Protection.AllowInsertingHyperlinks,
                this.Protection.AllowDeletingColumns,
                this.Protection.AllowDeletingRows,
                this.Protection.AllowSorting,
                this.Protection.AllowFiltering,
                this.Protection.AllowUsingPivotTables);
        }
    }
}
Private Sub ProtectShapes()
    If Not Me.ProtectDrawingObjects Then
        If DialogResult.Yes = MessageBox.Show("Shapes in this worksheet " & _
            "are not protected. Protect shapes the worksheet?", "Example", _
            MessageBoxButtons.YesNo) Then

            ' Protect shapes, but do not change any 
            ' other protection type.
             Me.Protect(DrawingObjects:=True, _
                Contents:=Me.ProtectContents, Scenarios:=Me.ProtectScenarios, _
                UserInterfaceOnly:=Me.ProtectionMode, _
                AllowFormattingCells:=Me.Protection.AllowFormattingCells, _
                AllowFormattingColumns:=Me.Protection.AllowFormattingColumns, _
                AllowFormattingRows:=Me.Protection.AllowFormattingRows, _
                AllowInsertingColumns:=Me.Protection.AllowInsertingColumns, _
                AllowInsertingRows:=Me.Protection.AllowInsertingRows, _
                AllowInsertingHyperlinks:=Me.Protection.AllowInsertingHyperlinks, _
                AllowDeletingColumns:=Me.Protection.AllowDeletingColumns, _
                AllowDeletingRows:=Me.Protection.AllowDeletingRows, _
                AllowSorting:=Me.Protection.AllowSorting, _
                AllowFiltering:=Me.Protection.AllowFiltering, _
                AllowUsingPivotTables:=Me.Protection.AllowUsingPivotTables)
        End If
    End If

End Sub 'ProtectShapes

Aplica-se a