Friday, July 04, 2008  



 FarPoint Technologies
 (800) 645-5913

 fpsales@fpoint.com



     
 »Spread for Windows Forms » Product Tour » User Interaction » Selection

Previous Customizing User Selection of Data Next

You can control what the user can select and how it appears.

  Back to Top
 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. 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.

You can control whether users can only select:
  • Cells
  • Rows
  • Columns
  • Sheet
  • Combination
  • Cells, ranges of cells, or multiple ranges of cells
  • Only rows, no editing
  • Only rows, editing
  • Multiple contiguous rows, no editing
  • Multiple noncontiguous rows, no editing
// Users can select only Columns and not rows or cells
fpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Columns;

' Users can select only Columns and not rows or cells
FpSpread1.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Columns


  Back to Top
 Customizing the Selection Indicator
Selections have a default appearance provided by the control and the selection renderer. You can change that appearance, including the background and foreground colors and gradients.

By default, the control uses the appearance set by the selection renderer. When something is selected, the renderer changes the color of the background of the selection. Instead of using this rendering, you can specify specific colors to use for the background and text colors of selections. Alternatively, you can use both the renderer's appearance and colors you set. Finally, you can specify that no appearance is used to highlight selections.

// Use the selection renderer and colors
fpSpread1.Sheets[0].SelectionStyle = FarPoint.Win.Spread.SelectionStyles.Both;
fpSpread1.Sheets[0].SelectionBackColor =System.Drawing.Color.AliceBlue;
fpSpread1.Sheets[0].SelectionForeColor = System.Drawing.Color.Navy;

' Use the selection renderer and colors
FpSpread1.Sheets(0).SelectionStyle = FarPoint.Win.Spread.SelectionStyles.Both
FpSpread1.Sheets(0).SelectionBackColor = System.Drawing.Color.AliceBlue
FpSpread1.Sheets(0).SelectionForeColor = System.Drawing.Color.Navy


  Back to Top
 Working with Selections
Besides selections occurring as a normal part of using the spreadsheet, you can add selections to the sheet using code. You can also return existing selections, and remove one or all of the existing selections.
  • To add a selection, use the Sheets AddSelection method and specify the starting row and column, and the number of rows and columns in the selection.
  • To return all existing selections, use the Sheets GetSelection method. To return a specific selection, use the Sheets GetSelection method.
  • To remove all selections, use the Sheets ClearSelection method. To remove a specific selection, use the Sheets RemoveSelection method and specify the row and column, and the number of rows and columns to remove from the selection.
// Select a range of cells
fpSpread1.Sheets[0].SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange;
fpSpread1.Sheets[0].AddSelection(2, 2, 2, 2);

' Select a range of cells
FpSpread1.Sheets(0).SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
FpSpread1.Sheets(0).AddSelection(2, 2, 2, 2)





Previous Customizing User Selection of Data Next

    
 Have a question?
Have a Question? Ask Us!
Subscribe to the RSS feed!RSS Subscribe
 

 
SD Times 'TOP 100' Industry Innovator - Read the press release (pdf)

Tour Home
Overview
Appearance
User Interaction
Cell Types
Formulas
Managing Data
Data Binding
Import/Export
Printing
Keyboard Interaction
Shapes
Models
Spread Designer
 
Map

Copyright © 1991-2007 FarPoint Technologies, Inc. All rights reserved. All names are property of their respective owners.