WorksheetBase.EnableSelection 属性

获取或设置一个值,该值指示在工作表上可以选择哪些单元格。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public Property EnableSelection As XlEnableSelection
    Get
    Set
public XlEnableSelection EnableSelection { get; set; }

属性值

类型:Microsoft.Office.Interop.Excel.XlEnableSelection
XlEnableSelection 值之一。

备注

仅当工作表受保护时,此属性才生效:xlNoSelection 禁止在表上进行任何选择,xlUnlockedCells 仅允许选择那些未锁定的单元格,而 xlNoRestrictions 允许选择任意单元格。

示例

下面的代码示例使用 Protect 方法保护工作表,然后使用 EnableSelection 属性禁止选择工作表上的任何单元格。

此示例针对的是文档级自定义项。

Private Sub ProtectAndDisableSelection()
    Me.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, _
        UserInterfaceOnly:=True, AllowFormattingCells:=True, _
        AllowFormattingColumns:=False, AllowFormattingRows:=False, _
        AllowInsertingColumns:=False, AllowInsertingRows:=False, _
        AllowInsertingHyperlinks:=False, AllowDeletingColumns:=False, _
        AllowDeletingRows:=False, AllowSorting:=True, AllowFiltering:=True, _
        AllowUsingPivotTables:=True)
    Me.EnableSelection = Excel.XlEnableSelection.xlNoSelection
End Sub
private void ProtectAndDisableSelection()
{
    this.Protect(missing, true, true, true, true, true,
        false, false, false, false, false, false, false, true,
        true, true);
    this.EnableSelection = Excel.XlEnableSelection.xlNoSelection;
}

.NET Framework 安全性

请参见

参考

WorksheetBase 类

Microsoft.Office.Tools.Excel 命名空间