Limiting Values for a Numeric Cell
In This Topic
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.
The cell types that allow you to set a minimum and maximum value are:
For more information about these cell types, refer to the following topics:
For information on other features of cell types, refer to Understanding Additional Features of Cell Types.
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 in which the cells appear.
- In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
- Select the cells for which you want to set the cell type.
- In the property list, select the CellType property and choose the Currency, Number, Percent, Progress, or Slider cell type.
- Expand the list of properties under the CellType property. Select and set the MaximumValue and MinimumValue properties to the highest and lowest allowable currency values.
- Click OK to close the Cell, Column, and Row Editor.
- Click OK to close the SheetView Collection Editor.
Using Code
- Set the minimum or maximum value or both for a currency cell by setting the MaximumValue and MinimumValue properties for a CurrencyCellType, NumberCellType, PercentCellType, ProgressCellType, or SliderCellType object.
- Assign the cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the particular cell type object.
Example
This example creates a currency cell and sets the minimum and maximum values.
C# |
Copy Code
|
FarPoint.Win.Spread.CellType.CurrencyCellType currcell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
currcell.MinimumValue = 1;
currcell.MaximumValue = 10;
fpSpread1.ActiveSheet.Cells[1,1].CellType = currcell;
fpSpread1.ActiveSheet.Cells[1,1].Note = "Pick a number between 1 and 10!";
|
VB |
Copy Code
|
Dim currcell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
currcell.MinimumValue = 1
currcell.MaximumValue = 10
fpSpread1.ActiveSheet.Cells(1,1).CellType = currcell
fpSpread1.ActiveSheet.Cells(1,1).Note = "Pick a number between 1 and 10!"
|
Using the Spread Designer
- Select the cell or cells in the work area.
- In the property list, in the Misc category, select CellType (or right-click on the cells and select the cell type). From the drop-down list, choose Currency or other numeric cell type. Now expand the CellType property and various properties are available that are specific to this cell type.
- Select and set the MaximumValue and MinimumValue properties to the highest and lowest allowable currency values.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
See Also