Export (0) Print
Expand All
Expand Minimize

WorksheetBase.EnableSelection Property

Gets or sets a value indicating which cells can be selected on the sheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public XlEnableSelection EnableSelection { get; set; }

This property takes effect only when the worksheet is protected: xlNoSelection prevents any selection on the sheet, xlUnlockedCells allows only those cells that are not locked to be selected, and xlNoRestrictions allows any cell to be selected.

The following code example uses the Protect method to protect the worksheet, and then uses the EnableSelection property to prevent any cell on the worksheet from being selected.

This example is for a document-level customization.

private void ProtectAndDisableSelection()
{
    this.Protect(true, true, true, true, true,
        false, false, false, false, false, false, false, true,
        true, true);
    this.EnableSelection = Excel.XlEnableSelection.xlNoSelection;
}

Show:
© 2014 Microsoft