Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Editable Cell Types > Setting a Percent Cell |
You can use a percent cell for displaying values as percentages and restricting inputs to percentage numeric values.
You use the PercentCellType class to set the percent cell and its properties.
By default, no spin buttons are shown, but you can display spin buttons on the side of the cell when the cell is in edit mode. You can set various spin functions using the properties of the PercentCellType class that begin with the word Spin. Refer to Displaying Spin Buttons.
By default, in a percent cell, if you double-click on the cell in edit mode at run-time, a pop-up calculator appears. You can determine whether to allow this, and you can specify the text that displays in the OK and Cancel buttons. For more information, refer to Customizing the Pop-Up Calculator Control. To prohibit the popping up of the calculator, cancel the FpSpread SubEditorOpening event. Handle this event and set the Cancel argument of the SubEditorOpeningEventArgs to True.
For more information on the properties and methods of this cell type, refer to the PercentCellType class.
This example sets a cell to be a percent cell and displays an abbreviation (PRCNT) instead of the percent sign (%).
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.PercentCellType prctcell = new FarPoint.Win.Spread.CellType.PercentCellType(); prctcell.PercentSign = "PRCNT"; prctcell.PositiveFormat = FarPoint.Win.Spread.CellType.PercentPositiveFormat.PercentBefore; fpSpread1.ActiveSheet.Cells[1, 1].CellType = prctcell; |
VB |
Copy Code
|
---|---|
Dim prctcell As New FarPoint.Win.Spread.CellType.PercentCellType() prctcell.PercentSign = "PRCNT" prctcell.PositiveFormat = FarPoint.Win.Spread.CellType.PercentPositiveFormat.PercentBefore FpSpread1.ActiveSheet.Cells(1, 1).CellType = prctcell |
Or right-click on the cell or cells and select Cell Type. From the list, select Percent. In the CellType editor, set the properties you need. Click Apply.