Saturday, October 11, 2008  



 FarPoint Technologies
 (800) 645-5913

 fpsales@fpoint.com



     
 »Spread for Windows Forms » Product Tour » Cell Types » Editable

Previous Working with Editable Cell Types Next

  Back to Top
 Setting a Currency Cell
You can set a cell to display currency and only allow user inputs of currency values. You can set the minimum and maximum values that can be entered in a cell and notify the user with a message if the entry is smaller than the minimum or larger than the maximum. You can also specify whether the cell allows multiple lines. By default, Spread uses the regional Windows settings (or options) for the formatting of currency.

You can specify the:
  • currency symbol (and whether to display it)
  • separator character (and whether to display it)
  • decimal symbol
  • whether to display a leading zero
  • positive currency format
  • negative currency format
  • minimum and maximum values that can be entered.
// Create a currency cell
FarPoint.Win.Spread.CellType.CurrencyCellType currcell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currcell.CurrencySymbol = "US$";
currcell.DecimalSeparator = ":";
currcell.DecimalPlaces = 8;
currcell.MinimumValue = 1;
currcell.MaximumValue = 10;
fpSpread1.ActiveSheet.Cells[1,1].CellType = currcell;

' Create a currency cell
Dim currcell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currcell.CurrencySymbol = "US$"
currcell.DecimalSeparator = ":"
currcell.DecimalPlaces = 8
currcell.MinimumValue = 1
currcell.MaximumValue = 10
FpSpread1.ActiveSheet.Cells(1,1).CellType = currcell 


  Back to Top
 Setting a Date-Time Cell
You can set a cell to display date and time and only allow user inputs of date and time. You determine the format of the date and time to display. The default values use the Regional Settings or Regional Options in the Windows environment.

// Create a dateTime cell
FarPoint.Win.Spread.CellType.DateTimeCellType datecell = new FarPoint.Win.Spread.CellType.DateTimeCellType();
fpSpread1.ActiveSheet.Cells[1, 1].CellType = datecell;

' Create a dateTime cell
Dim datecell As New FarPoint.Win.Spread.CellType.DateTimeCellType()
FpSpread1.ActiveSheet.Cells(1, 1).CellType = datecell


If you press F4 or double-click a date-time cell when it is in edit mode, a pop-up calendar appears. The date you choose from the calendar is placed in the date-time cell. You can specify normal and abbreviated day names, normal and abbreviated month names, localize the month and day names, and the text for OK and Cancel buttons to appear in the calendar for all Spread controls.



  Back to Top
 Setting a General Cell
The General CellType is the default for all cells. Similar to General cell in Microsoft Excel, the General celltype accepts input of data and coerces it into one of the known formats and data types. Enter a date, Spread stores it as a date. Enter a number, Spread stores it as a number. This frees the developer from having to set a specific cell type where the data input may not be yet known. You can also specify a specific format string and the general formatter will parse the user-entered data, but when the data is displayed, the specified format string is used rather than the format used by the end user.

// Create a general cell
FarPoint.Win.Spread.CellType.GeneralCellType gnrlcell = new FarPoint.Win.Spread.CellType.GeneralCellType();
fpSpread1.ActiveSheet.Cells[1, 1].CellType = gnrlcell;

' Create a general cell
Dim gnrlcell As New FarPoint.Win.Spread.CellType.GeneralCellType()
FpSpread1.ActiveSheet.Cells(1, 1).CellType = gnrlcell




  Back to Top
 Setting a Mask Cell
You can use a mask cell for masking characters to limit user entry. You specify which subsets of characters are allowed for each item in the mask. You can define how the mask appears, with literals displayed exactly as typed and placeholders showing the places for user entry. To create a mask, set the Mask property to a string of mask characters. Each mask character represents a position in which the user can type a character.

// Create a mask cell for a US phone number
FarPoint.Win.Spread.CellType.MaskCellType maskcell = new FarPoint.Win.Spread.CellType.MaskCellType();
maskcell.Mask = "(###) ###-####";
maskcell.MaskChar = Convert.ToChar("_");
fpSpread1.ActiveSheet.Cells[1, 1].CellType = maskcell;

' Create a mask cell for a US phone number
Dim maskcell As New FarPoint.Win.Spread.CellType.MaskCellType()
maskcell.Mask = "(###) ###-####"
maskcell.MaskChar = "_"
FpSpread1.ActiveSheet.Cells(1, 1).CellType = maskcell




  Back to Top
 Setting a Number Cell
You can use an number cell for entering double-precision floating point numbers. Numbers are typically calculated and stored using the Double data type which provides an accuracy of about 15 digits. The cell can be formatted to display as many or as few digits as desired.

// Create a number cell and set a few options
FarPoint.Win.Spread.CellType.NumberCellType nmbrcell = new FarPoint.Win.Spread.CellType.NumberCellType();
nmbrcell.DecimalSeparator = ",";
nmbrcell.DecimalPlaces = 5;
nmbrcell.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.UseRegional;
nmbrcell.MaximumValue = 500.000;
nmbrcell.MinimumValue = -10.000;
fpSpread1.ActiveSheet.Cells[1, 1].CellType = nmbrcell;

' Create a number cell and set a few options
Dim nmbrcell As New FarPoint.Win.Spread.CellType.NumberCellType()
nmbrcell.DecimalSeparator = ","
nmbrcell.DecimalPlaces = 5
nmbrcell.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.UseRegional
nmbrcell.MaximumValue = 500.000
nmbrcell.MinimumValue = -10.000
FpSpread1.ActiveSheet.Cells(1, 1).CellType = nmbrcell




  Back to Top
 Setting a Percent Cell
You can use a percent cell for displaying values as percentages and restricting inputs to percentage numeric values.

// Create a percent cell and set a few options
FarPoint.Win.Spread.CellType.PercentCellType prctcell = new FarPoint.Win.Spread.CellType.PercentCellType();
prctcell.PercentSign = "%";
prctcell.PositiveFormat = FarPoint.Win.Spread.CellType.PercentPositiveFormat.PercentSignBeforeWithSpace;
fpSpread1.ActiveSheet.Cells[1, 1].CellType = prctcell;

' Create a percent cell and set a few options
Dim prctcell As New FarPoint.Win.Spread.CellType.PercentCellType()
prctcell.PercentSign = "%"
prctcell.PercentPositiveFormat = FarPoint.Win.Spread.CellType.PercentPositiveFormat.PercentSignBeforeWithSpace
FpSpread1.ActiveSheet.Cells(1, 1).CellType = prctcell




  Back to Top
 Setting a Regular Expression Cell
You can create a regular expression cell that restricts the way data is entered in the cell to valid entries defined in a regular expression. The data is evaluated when exiting the cell. Invalid data is removed and the EditError event is raised.

// Create a regular expression cell
FarPoint.Win.Spread.CellType.RegularExpressionCellType regexcell = new FarPoint.Win.Spread.CellType.RegularExpressionCellType()
regexcell.RegularExpression = "[0-9]{3}-[0-9]{2}-[0-9]{4}";
fpSpread1.ActiveSheet.Cells[0, 0].CellType = regexcell;

' Create a regular expression cell
Dim regexcell As New FarPoint.Win.Spread.CellType.RegularExpressionCellType()
regexcell.RegularExpression = "[0-9]{3}-[0-9]{2}-[0-9]{4}"
FpSpread1.ActiveSheet.Cells(0, 0).CellType = regexcell




  Back to Top
 Setting a Text Cell
You can create a text cell that allows only text to be displayed or treats the contents of a cell as only text.

// Create a text cell and set some options
FarPoint.Win.Spread.CellType.TextCellType tcell = new FarPoint.Win.Spread.CellType.TextCellType()
tcell.CharacterCasing = CharacterCasing.Upper;
tcell.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii;
tcell.MaxLength = 30;
tcell.Multiline = true;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = tcell;

' Create a text cell and set some options
Dim tcell As New FarPoint.Win.Spread.CellType.TextCellType()
tcell.CharacterCasing = CharacterCasing.Upper
tcell.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii
tcell.MaxLength = 40
tcell.Multiline = True
FpSpread1.ActiveSheet.Cells(0, 0).CellType = tcell




  Back to Top
 Displaying Spin Buttons
In some cell types, you can display spin buttons, to let users change the value in a cell quickly. You specify how much the value changes when the user clicks either of the spin buttons and you determine whether the value wraps when the minimum or maximum value is reached.

For the numeric cell types, if the cursor is left of the decimal point, the spin button increments the value using the whole number. If the cursor is to the right, the spin button increments the value using the first, or tenths, decimal place. For the date-time cell type, the day, month, year, etc. are incremented or decremented depending on which part of the date and time the cursor is in.

Spin buttons can be displayed in:
  • Currency Cells
  • Date-Time Cells
  • Number Cells
  • Percent Cells


  Back to Top
 Displaying a Calculator
If the user presses F4 or double-clicks any of the several numeric cell types when the cell is in edit mode, a pop-up calculator appears that the customer can use.

You can use the calculator to type a number or to perform a calculation. The result from the calculator is placed in the numeric cell. The cell types that allow a calculator pop-up are:
  • Currency Cells
  • Number Cells
  • Percent Cells

Previous Working with Editable Cell Types Next

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

 
Learn about the new Roadshow now!

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.