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 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 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 enum and the SelectionBlockOptions enum.Return to Customizing User Selection of Data.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet for which to set the operation mode.
- Select the OperationMode property, then select one of the values from the drop-down list of values.
- 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.
- 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.
- Click OK to close the editor.
- 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
- To set the overall user interaction mode of the sheet, set the Sheets OperationMode property.
- If you set the OperationMode property to Normal,
- 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.
- 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.
- 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
- To set the overall user interaction mode of the sheet, set the OperationMode property for a SheetView object.
- If you set the OperationMode property to Normal,
- 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.
- 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.
- 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.
- 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
- Select the sheet tab for the sheet for which you want to set the selection operation mode.
- 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.
- Click OK to close the Sheet Settings dialog.
- If you set the OperationMode property to Normal,
- 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.
- 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.
- 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.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.