Spread Windows Forms 11.0 Product Documentation
Specifying What the User Can Select
Spread Windows Forms 11.0 Product Documentation > Developer's Guide > Customizing Sheet Interaction > Customizing User Selection of Data > Specifying What the User Can Select

By default, sheets allow users to select a cell, a column, a row, a range of cells, or the entire sheet. You can customize how selection occurs and what can be selected by working with the operation mode of the sheet and with the selection policy and selection unit of the sheet.

The following table summarizes the options available for specifying what users can select:

What user can select When setting this for the sheet
Cells FpSpread.SelectionBlockOptions.Cells
Rows FpSpread.SelectionBlockOptions.Rows
Columns FpSpread.SelectionBlockOptions.Columns
Sheet FpSpread.SelectionBlockOptions.Sheet
Combination FpSpread.SelectionBlockOptions.number where number is some addition of the numbers for the individual settings (such as 6 = 2 + 4, Rows and Columns)
Cells, ranges of cells, or multiple ranges of cells OperationMode.Normal with SelectionPolicy property
Only rows, no editing OperationMode.SingleSelect
Only rows, editing OperationMode.RowMode
Multiple contiguous rows, no editing OperationMode.MultiSelect
Multiple noncontiguous rows, no editing OperationMode.ExtendedSelect

Note that the FpSpread.SelectionBlockOptions are settings at the Spread component level, while the OperationMode settings are at the sheet level.

The settings of the OperationMode and the SelectionBlockOptions properties affect user interaction with the sheet, that is, what the user can select, but not necessarily what the application can select. If you want to customize what the user and the application both can select, set the SelectionUnit property.

You can also restrict which cells can be edited by using the RestrictRows and RestrictColumns methods for the sheet. This restricts users from entering data beyond the next row or column. For more information, refer to the SelectionPolicy property and the SelectionUnit property of the SheetView class, and the SelectionBlockOptions property of the FpSpread class. For more details, see the OperationMode  and the SelectionBlockOptions enumerations.

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.
  2. Select the Sheets property.
  3. Click the button to display the SheetView Collection Editor.
  4. In the Members list, select the sheet for which to set the operation mode.
  5. Select the OperationMode property, then select one of the values from the drop-down list of values.
  6. If you set the OperationMode property to Normal, and you want to allow users to select only a cell or to select multiple ranges of cells, set the SelectionPolicy property to Single or to MultiRange.
  7. To set the overall selection interaction for the sheet, including how users and the application can select items, set the SelectionUnit property to specify the unit of selection allowed.
  8. Click OK to close the editor.
  9. If you want to customize what users can select in all sheets in the Spread component, set the SelectionBlockOptions property to specify whether they can select cells, columns, rows, the sheet or a combination of these.

Using a Shortcut

  1. To set the overall user interaction mode of the sheet, set the Sheets OperationMode property.
  2. If you set the OperationMode property to Normal,
    1. If you want to customize what users can select in all sheets in the Spread component, set the FpSpread SelectionBlockOptions property to specify whether they can select cells, columns, rows, the sheet or a combination of these.
    2. If you want to allow users to select only a cell or to select multiple ranges of cells, set the Sheets SelectionPolicy property to Single or to MultiRange.
  3. To set the overall selection interaction for the sheet, including how users and the application can select items, set the Sheets SelectionUnit property to specify the unit of selection allowed.

Example

This example code sets the sheet to allow users to select only cells or ranges of cells, including multiple ranges of cells. They cannot select columns, rows, or the entire sheet in this example.

C#
Copy Code
// Set option so users can select only cells.
fpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells;// Set operation mode and let users select multiple blocks of cells.fpSpread1.Sheets[0].OperationMode = FarPoint.Win.Spread.OperationMode.Normal;
fpSpread1.Sheets[0].SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange;
VB
Copy Code
' Set option so users can select only cells.
fpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells
' Set operation mode and let users select multiple blocks of cells.
fpSpread1.Sheets(0).OperationMode = FarPoint.Win.Spread.OperationMode.Normal
fpSpread1.Sheets(0).SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange

Using Code

  1. To set the overall user interaction mode of the sheet, set the OperationMode property for a SheetView object.
  2. If you set the OperationMode property to Normal,
    1. If you want to customize what users can select in all sheets in the Spread component, set the FpSpread SelectionBlockOptions property to specify whether they can select cells, columns, rows, the sheet or a combination of these.
    2. If you want to allow users to select only a cell or to select multiple ranges of cells, set the SheetView object SelectionPolicy property to Single or to MultiRange.
  3. To set the overall selection interaction for the sheet, including how users and the application can select items, set the SheetView object SelectionUnit property to specify the unit of selection allowed.
  4. Assign the SheetView object you have created to one of the sheets in the Spread component.

Example

This example code sets the sheet to allow users to select only cells or ranges of cells, including multiple ranges of cells. They cannot select columns, rows, or the entire sheet in this example.

C#
Copy Code
// Set option so users can select only cells.
fpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells;// Set operation mode and let users select multiple blocks of cells.
FarPoint.Win.Spread.SheetView newsheet = new FarPoint.Win.Spread.SheetView();
newsheet.OperationMode = FarPoint.Win.Spread.OperationMode.Normal;
newsheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange;
// Assign the SheetView object to a sheet.
fpSpread1.Sheets[0] = newsheet;
VB
Copy Code
' Set option so users can select only cells.
fpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Cells
' Set operation mode and let users select multiple blocks of cells.
Dim newsheet As New FarPoint.Win.Spread.SheetView()
newsheet.OperationMode = FarPoint.Win.Spread.OperationMode.Normal
newsheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
' Assign the SheetView object to a sheet.
fpSpread1.Sheets(0) = newsheet

Using the Spread Designer

  1. Select the sheet tab for the sheet for which you want to set the selection operation mode.
  2. From the Settings menu, select general (Sheet Settings section). In the Sheet Settings dialog, on the General tab, select one of the choices from the Operation Mode area.
  3. Click OK to close the Sheet Settings dialog.
  4. If you set the OperationMode property to Normal,
    1. If you want to customize what users can select in all sheets in the Spread component, set the SelectionBlockOptions property (for the selected Spread) in the Properties list to specify whether they can select cells, columns, rows, the sheet or a combination of these.
    2. If you want to allow users to select only a cell or to select multiple ranges of cells, set the SelectionPolicy property (for the selected Sheet) in the Properties list to Single or to MultiRange.
  5. To set the overall selection interaction for the sheet, including how users and the application can select items, set the SelectionUnit property (for the selected Sheet) in the Properties list to specify the unit of selection allowed.
  6. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.