Proprietà WorksheetBase.ProtectionMode

Ottiene un valore che indica se la protezione della sola interfaccia utente è attivata.

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

Sintassi

'Dichiarazione
Public ReadOnly Property ProtectionMode As Boolean
    Get
public bool ProtectionMode { get; }

Valore proprietà

Tipo: System.Boolean
true se la protezione della sola interfaccia utente è attivata; in caso contrario, false.

Note

Per attivare la protezione dell'interfaccia utente, utilizzare il metodo Protect con l'argomento UserInterfaceOnly impostato su true.

Esempi

Nell'esempio di codice riportato di seguito viene ottenuto il valore della proprietà ProtectionMode per determinare se l'interfaccia utente è protetta. Se l'interfaccia utente non è protetta, viene chiamato il metodo Protect con il parametro UserInterfaceOnly impostato su true in modo da attivare la protezione dell'interfaccia utente.

Questo esempio è valido per una personalizzazione a livello di documento.

Private Sub ProtectUserInterface()
    If Not Me.ProtectionMode Then
        If DialogResult.Yes = MessageBox.Show("User interface protection is " & _
            "turned off. Turn on user interface protection?", "Example", _
            MessageBoxButtons.YesNo) Then

            ' Enable user interface protection, but do not change 
            ' any other protection type.
            Me.Protect(DrawingObjects:=Me.ProtectDrawingObjects, _
                Contents:=Me.ProtectContents, Scenarios:=Me.ProtectScenarios, _
                UserInterfaceOnly:=True, _
                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
private void ProtectUserInterface()
{
    if (!this.ProtectionMode)
    {
        if (DialogResult.Yes == MessageBox.Show("User interface protection is " +
            "turned off. Turn on user interface protection?", "Example",
            MessageBoxButtons.YesNo))
        {
            // Enable user interface protection, but do not change 
            // any other protection type.
            this.Protect(missing, this.ProtectDrawingObjects,
                this.ProtectContents, this.ProtectScenarios,
                true, 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);
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

WorksheetBase Classe

Spazio dei nomi Microsoft.Office.Tools.Excel