WorksheetBase.ProtectionMode Özellik
Kullanıcı yalnızca arabirim Koruması özelliğinin açık olup olmadığını gösteren bir değeri alır.
Ad alanı: Microsoft.Office.Tools.Excel
Derleme: Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll içinde)
Sözdizimi
'Bildirim
Public ReadOnly Property ProtectionMode As Boolean
Get
public bool ProtectionMode { get; }
Özellik Değeri
Tür: System.Boolean
true Kullanıcı yalnızca arabirim koruması etkinse; Aksi takdirde, false.
Açıklamalar
Kullanıcı arabirimi koruma'yı etkinleştirmek için Protect yöntemi ile UserInterfaceOnly değişkenini true.
Örnekler
Aşağıdaki kod örneği değeri alır ProtectionMode kullanıcı arabirimi korumalı olup olmadığını belirlemek için özellik. Kullanıcı arabirimi korumasız, ise daha sonra Protect yöntemi ile çağrılır UserInterfaceOnly parametresini ayarlamak true böylece kullanıcı arabirimi korumalı.
Bu örnek, bir belge düzeyinde özelleştirme için bulunur.
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 Güvenliği
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. kısmen güvenilir kod tarafından Kitaplıklar kullanma.