Spread.Sheets Documentation > Developer's Guide > Managing the User Interface > Working with Selections |
You can select cells, rows, columns, or multiple ranges in the widget.
Click and drag with the left mouse button to select a block of cells, columns, or rows. You can use the mouse click and Ctrl key to select multiple ranges of cells. Navigation keys are listed in Using Keyboard Navigation.
You can specify the type of selection unit (cell, column, or row) with the selectionUnit method. You can specify the range of the selection (single, range, or multiple range) with the selectionPolicy method.
You can set the selection color and border with the options.selectionBackColor and options.selectionBorderColor properties. You can use standard colors and theme colors.
This example selects a range of cells.
JavaScript |
Copy Code
|
---|---|
activeSheet.addSelection(4, 0, 2, 2); //activeSheet.clearSelection(); var sels = activeSheet.getSelections(); alert(sels.length); |
This example allows single row or block row selection.
JavaScript |
Copy Code
|
---|---|
activeSheet.selectionUnit(GC.Spread.Sheets.SelectionUnit.Row); activeSheet.selectionPolicy(GC.Spread.Sheets.SelectionPolicy.Range); |
This example sets the color for the selected area and border.
JavaScript |
Copy Code
|
---|---|
activeSheet.options.selectionBackColor = "Accent 6"; activeSheet.options.selectionBorderColor = "Accent 1"; |