Spread Windows Forms 8.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 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 and the SelectionBlockOptions enumerations.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 |
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 |