다음을 통해 공유


WorksheetBase.ProtectionMode 속성

사용자 인터페이스 전용 보호 기능이 설정되어 있는지 여부를 나타내는 값을 가져옵니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel.v4.0.Utilities(Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

구문

‘선언
Public ReadOnly Property ProtectionMode As Boolean
    Get
public bool ProtectionMode { get; }

속성 값

형식: System.Boolean
사용자 인터페이스 전용 보호 기능이 설정되어 있으면 true이고, 그렇지 않으면 false입니다.

설명

사용자 인터페이스 보호를 설정하려면 Protect 메서드를 UserInterfaceOnly 인수와 함께 사용하여 true로 설정합니다.

예제

다음 코드 예제에서는 ProtectionMode 속성의 값을 가져와 사용자 인터페이스가 보호되어 있는지 여부를 확인합니다. 사용자 인터페이스가 보호되어 있지 않으면 UserInterfaceOnly 매개 변수를 true로 설정하여 Protect 메서드를 호출함으로써 사용자 인터페이스를 보호합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

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

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

WorksheetBase 클래스

Microsoft.Office.Tools.Excel 네임스페이스