Operation Restrictions
- 5 minutes to read
Use the SpreadsheetControlOptions.Behavior property to access the Spreadsheet control’s restriction settings. You can set these options to the following values:
DocumentCapability.Default or DocumentCapability.Enabled - permits the specified spreadsheet operation.
DocumentCapability.Disabled - restricts the specified spreadsheet operation and disables the corresponding items in the control’s ribbon UI and context menus.
DocumentCapability.Hidden - restricts the specified spreadsheet operation and hides the corresponding items in the control’s ribbon UI and context menus.
Disable Workbook Operations
Use the following properties to restrict operations users can perform on workbooks:
Restriction | Description |
---|---|
SpreadsheetBehaviorOptions.CreateNew | Specifies whether users can create new documents. |
SpreadsheetBehaviorOptions.Open | Specifies whether users can open documents. |
SpreadsheetBehaviorOptions.Drop | Specifies whether users can drag and drop files onto the Spreadsheet control. |
SpreadsheetBehaviorOptions.Save | Specifies whether users can save changes in an existing document. |
SpreadsheetBehaviorOptions.SaveAs | Specifies whether users can save new documents. |
SpreadsheetProtectionBehaviorOptions.ProtectWorkbook | Specifies whether users can protect workbooks. |
SpreadsheetProtectionBehaviorOptions.UnprotectWorkbook | Specifies whether users can remove workbook protection. |
SpreadsheetBehaviorOptions.Encrypt | Specifies whether users can encrypt documents with a password. |
SpreadsheetBehaviorOptions.Print | Specifies whether users can print documents. |
The example below shows how to disable the New and Open operations in the Spreadsheet control.
spreadsheetControl.Options.Behavior.CreateNew = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Open = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
Disable Worksheet Operations
Use the following properties to restrict operations users can perform on worksheets:
Restriction | Description |
---|---|
SpreadsheetWorksheetBehaviorOptions.Insert | Specifies whether users can insert worksheets. |
SpreadsheetWorksheetBehaviorOptions.Delete | Specifies whether users can delete worksheets. |
SpreadsheetWorksheetBehaviorOptions.Hide | Specifies whether users can hide worksheets. |
SpreadsheetWorksheetBehaviorOptions.Unhide | Specifies whether users can unhide worksheets. |
SpreadsheetWorksheetBehaviorOptions.Rename | Specifies whether users can rename worksheets. |
SpreadsheetProtectionBehaviorOptions.ProtectSheet | Specifies whether users can protect worksheets. |
SpreadsheetProtectionBehaviorOptions.UnprotectSheet | Specifies whether users can remove worksheet protection. |
SpreadsheetWorksheetBehaviorOptions.TabColor | Specifies whether users can apply a background color to sheet tabs. |
SpreadsheetBehaviorOptions.OfficeScrolling | Specifies whether automatic scrolling is enabled. |
SpreadsheetBehaviorOptions.Zooming | Specifies whether users can zoom in and out of worksheets. |
SpreadsheetBehaviorOptions.MaxZoomFactor | Defines the maximum zoom factor. |
SpreadsheetBehaviorOptions.MinZoomFactor | Defines the minimum zoom factor. |
The example below shows how to hide the Delete Sheet and Hide Sheet commands in the Spreadsheet control.
spreadsheetControl.Options.Behavior.Worksheet.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden;
spreadsheetControl.Options.Behavior.Worksheet.Hide = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden;
Disable Row and Column Operations
Use the following properties to restrict operations users can perform on rows and columns:
Restriction | Description |
---|---|
SpreadsheetRowBehaviorOptions.Insert | Specifies whether users can insert rows. |
SpreadsheetRowBehaviorOptions.Delete | Specifies whether users can delete rows. |
SpreadsheetRowBehaviorOptions.Hide | Specifies whether users can hide rows. |
SpreadsheetRowBehaviorOptions.Unhide | Specifies whether users can unhide rows. |
SpreadsheetRowBehaviorOptions.Resize | Specifies whether users can resize rows. |
SpreadsheetRowBehaviorOptions.AutoFit | Specifies whether users can use AutoFit for rows. |
SpreadsheetColumnBehaviorOptions.Insert | Specifies whether users can insert columns. |
SpreadsheetColumnBehaviorOptions.Delete | Specifies whether users can delete columns. |
SpreadsheetColumnBehaviorOptions.Hide | Specifies whether users can hide columns. |
SpreadsheetColumnBehaviorOptions.Unhide | Specifies whether users can unhide columns. |
SpreadsheetColumnBehaviorOptions.Resize | Specifies whether users can resize columns. |
SpreadsheetColumnBehaviorOptions.AutoFit | Specifies whether users can use AutoFit for columns. |
SpreadsheetBehaviorOptions.FreezePanes | Specifies whether users can freeze rows and columns. |
SpreadsheetBehaviorOptions.Group | Specifies whether users can group or ungroup rows and columns. |
The example below shows how to disable the Delete operation for row and columns in the Spreadsheet control.
spreadsheetControl.Options.Behavior.Row.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Column.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
Disable Cell Operations
Use the following properties to restrict operations users can perform on cells and cell ranges:
Restriction | Description |
---|---|
SpreadsheetBehaviorOptions.Drag | Specifies whether users can drag cell ranges, drawings objects, and comments. |
SpreadsheetBehaviorOptions.MoveRange | Specifies whether users can move cell ranges. |
SpreadsheetBehaviorOptions.FillHandle | Allows you to show or hide the fill handle. |
SpreadsheetBehaviorOptions.CellEditor | Specifies whether the CellValueChanged event should occur each time a user edits a cell value or only if a value was changed. |
SpreadsheetSelectionOptions.AllowExtendSelection | Specifies whether users can use the mouse or arrow keys to extend the cell selection. |
SpreadsheetSelectionOptions.AllowMultiSelection | Specifies whether users can select multiple cell ranges or drawing objects in a worksheet. |
SpreadsheetSelectionOptions.HideSelection | Specifies whether to highlight the selected cells in the Spreadsheet control. |
SpreadsheetSelectionOptions.MoveActiveCellMode | Specifies the direction in which an active cell moves when the ENTER key is pressed. |
SpreadsheetSelectionOptions.ShowSelectionMode | Specifies whether to highlight selection when the Spreadsheet control does not have focus. |
SpreadsheetProtectionBehaviorOptions.AllowUsersToEditRange | Specifies whether users can grant permission to specific users to edit ranges in a protected worksheet. |
SpreadsheetBehaviorOptions.Comment | Specifies whether users can create or modify comments. |
SpreadsheetBehaviorOptions.DataValidation | Specifies whether users can create or modify data validation rules. |
SpreadsheetBehaviorOptions.UseSkinColors | Specifies whether to use skin colors for a cell’s font and background. |
The example below shows how to disable multiple selection in the Spreadsheet control and change the direction in which an active cell moves when a user presses ENTER.
spreadsheetControl1.Options.Behavior.Selection.AllowMultiSelection = false;
spreadsheetControl1.Options.Behavior.Selection.MoveActiveCellMode = DevExpress.XtraSpreadsheet.MoveActiveCellModeOnEnterPress.Right;
Disable Clipboard Operations
Use the following properties to restrict clipboard operations:
Restriction | Description |
---|---|
SpreadsheetBehaviorOptions.Cut | Specifies whether users can perform the Cut operation. |
SpreadsheetBehaviorOptions.Copy | Specifies whether users can perform the Copy operation. |
SpreadsheetBehaviorOptions.Paste | Specifies whether users can perform the Paste operation. |
The example below shows how to disable clipboard operations in the Spreadsheet control.
spreadsheetControl.Options.Behavior.Cut = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Copy = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Paste = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;