Back to Devexpress

Operation Restrictions

windowsforms-401195-controls-and-libraries-spreadsheet-operation-restrictions.md

latest15.9 KB
Original Source

Operation Restrictions

  • Oct 29, 2020
  • 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:

Disable Workbook Operations

Use the following properties to restrict operations users can perform on workbooks:

RestrictionDescription
SpreadsheetBehaviorOptions.CreateNewSpecifies whether users can create new documents.
SpreadsheetBehaviorOptions.OpenSpecifies whether users can open documents.
SpreadsheetBehaviorOptions.DropSpecifies whether users can drag and drop files onto the Spreadsheet control.
SpreadsheetBehaviorOptions.SaveSpecifies whether users can save changes in an existing document.
SpreadsheetBehaviorOptions.SaveAsSpecifies whether users can save new documents.
SpreadsheetProtectionBehaviorOptions.ProtectWorkbookSpecifies whether users can protect workbooks.
SpreadsheetProtectionBehaviorOptions.UnprotectWorkbookSpecifies whether users can remove workbook protection.
SpreadsheetBehaviorOptions.EncryptSpecifies whether users can encrypt documents with a password.
SpreadsheetBehaviorOptions.PrintSpecifies whether users can print documents.

The example below shows how to disable the New and Open operations in the Spreadsheet control.

csharp
spreadsheetControl.Options.Behavior.CreateNew = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Open = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
vb
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:

RestrictionDescription
SpreadsheetWorksheetBehaviorOptions.InsertSpecifies whether users can insert worksheets.
SpreadsheetWorksheetBehaviorOptions.DeleteSpecifies whether users can delete worksheets.
SpreadsheetWorksheetBehaviorOptions.HideSpecifies whether users can hide worksheets.
SpreadsheetWorksheetBehaviorOptions.UnhideSpecifies whether users can unhide worksheets.
SpreadsheetWorksheetBehaviorOptions.RenameSpecifies whether users can rename worksheets.
SpreadsheetProtectionBehaviorOptions.ProtectSheetSpecifies whether users can protect worksheets.
SpreadsheetProtectionBehaviorOptions.UnprotectSheetSpecifies whether users can remove worksheet protection.
SpreadsheetWorksheetBehaviorOptions.TabColorSpecifies whether users can apply a background color to sheet tabs.
SpreadsheetBehaviorOptions.OfficeScrollingSpecifies whether automatic scrolling is enabled.
SpreadsheetBehaviorOptions.ZoomingSpecifies whether users can zoom in and out of worksheets.
SpreadsheetBehaviorOptions.MaxZoomFactorDefines the maximum zoom factor.
SpreadsheetBehaviorOptions.MinZoomFactorDefines the minimum zoom factor.

The example below shows how to hide the Delete Sheet and Hide Sheet commands in the Spreadsheet control.

csharp
spreadsheetControl.Options.Behavior.Worksheet.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden;
spreadsheetControl.Options.Behavior.Worksheet.Hide = DevExpress.XtraSpreadsheet.DocumentCapability.Hidden;
vb
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:

RestrictionDescription
SpreadsheetRowBehaviorOptions.InsertSpecifies whether users can insert rows.
SpreadsheetRowBehaviorOptions.DeleteSpecifies whether users can delete rows.
SpreadsheetRowBehaviorOptions.HideSpecifies whether users can hide rows.
SpreadsheetRowBehaviorOptions.UnhideSpecifies whether users can unhide rows.
SpreadsheetRowBehaviorOptions.ResizeSpecifies whether users can resize rows.
SpreadsheetRowBehaviorOptions.AutoFitSpecifies whether users can use AutoFit for rows.
SpreadsheetColumnBehaviorOptions.InsertSpecifies whether users can insert columns.
SpreadsheetColumnBehaviorOptions.DeleteSpecifies whether users can delete columns.
SpreadsheetColumnBehaviorOptions.HideSpecifies whether users can hide columns.
SpreadsheetColumnBehaviorOptions.UnhideSpecifies whether users can unhide columns.
SpreadsheetColumnBehaviorOptions.ResizeSpecifies whether users can resize columns.
SpreadsheetColumnBehaviorOptions.AutoFitSpecifies whether users can use AutoFit for columns.
SpreadsheetBehaviorOptions.FreezePanesSpecifies whether users can freeze rows and columns.
SpreadsheetBehaviorOptions.GroupSpecifies 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.

csharp
spreadsheetControl.Options.Behavior.Row.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Column.Delete = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
vb
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:

RestrictionDescription
SpreadsheetBehaviorOptions.DragSpecifies whether users can drag cell ranges, drawings objects, and comments.
SpreadsheetBehaviorOptions.MoveRangeSpecifies whether users can move cell ranges.
SpreadsheetBehaviorOptions.FillHandleAllows you to show or hide the fill handle.
SpreadsheetBehaviorOptions.CellEditorSpecifies whether the CellValueChanged event should occur each time a user edits a cell value or only if a value was changed.
SpreadsheetSelectionOptions.AllowExtendSelectionSpecifies whether users can use the mouse or arrow keys to extend the cell selection.
SpreadsheetSelectionOptions.AllowMultiSelectionSpecifies whether users can select multiple cell ranges or drawing objects in a worksheet.
SpreadsheetSelectionOptions.HideSelectionSpecifies whether to highlight the selected cells in the Spreadsheet control.
SpreadsheetSelectionOptions.MoveActiveCellModeSpecifies the direction in which an active cell moves when the ENTER key is pressed.
SpreadsheetSelectionOptions.ShowSelectionModeSpecifies whether to highlight selection when the Spreadsheet control does not have focus.
SpreadsheetProtectionBehaviorOptions.AllowUsersToEditRangeSpecifies whether users can grant permission to specific users to edit ranges in a protected worksheet.
SpreadsheetBehaviorOptions.CommentSpecifies whether users can create or modify comments.
SpreadsheetBehaviorOptions.DataValidationSpecifies whether users can create or modify data validation rules.
SpreadsheetBehaviorOptions.UseSkinColorsSpecifies 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.

csharp
spreadsheetControl1.Options.Behavior.Selection.AllowMultiSelection = false;
spreadsheetControl1.Options.Behavior.Selection.MoveActiveCellMode = DevExpress.XtraSpreadsheet.MoveActiveCellModeOnEnterPress.Right;
vb
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:

RestrictionDescription
SpreadsheetBehaviorOptions.CutSpecifies whether users can perform the Cut operation.
SpreadsheetBehaviorOptions.CopySpecifies whether users can perform the Copy operation.
SpreadsheetBehaviorOptions.PasteSpecifies whether users can perform the Paste operation.

The example below shows how to disable clipboard operations in the Spreadsheet control.

csharp
spreadsheetControl.Options.Behavior.Cut = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Copy = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
spreadsheetControl.Options.Behavior.Paste = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled;
vb
spreadsheetControl.Options.Behavior.Cut = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled
spreadsheetControl.Options.Behavior.Copy = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled
spreadsheetControl.Options.Behavior.Paste = DevExpress.XtraSpreadsheet.DocumentCapability.Disabled

See Also

Add a Ribbon to the Spreadsheet Control

Customize Context Menus