Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Cell Types / Working with Editable Cell Types / Setting a Currency Cell
In This Topic
    Setting a Currency Cell
    In This Topic

    You can set a cell to display currency values using the currency cell. A currency cell displays the numeric currency values with formatting that you can customize including a currency symbol, a separator character, and other formatting.

    Currency Cells

    You use the CurrencyCellType class to set the currency cell and its properties.

    By default, Spread uses the regional Windows settings (or options) of the machine on which it runs for the formatting of currency. You can customize any of these currency formatting properties:

    By default, in a currency 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 on the OK and Cancel buttons. For more information, refer to Customizing the Pop-Up Calculator Control.

    You can also set the minimum and maximum values that can be entered to provide validation of the user entry. To define the limits for values, refer to Limiting Values for a Numeric Cell.

    Using Spin Buttons

    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 CurrencyCellType that begin with the word Spin. For more information, refer to Displaying Spin Buttons.

    For more information on the properties and methods of this cell type, refer to the CurrencyCellType class.

    Using the Properties Window

    1. At design time, in the Properties window, select the Spread component.
    2. Select the Sheets property.
    3. Click the button to display the SheetView Collection Editor.
    4. In the Members list, select the sheet in which the cells appear.
    5. In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
    6. Select the cells for which you want to set the cell type.
    7. In the property list, select the CellType property and choose the Currency cell type.
    8. Expand the list of properties under the CellType property. Select and set these specific properties as needed.
    9. Click OK to close the Cell, Column, and Row Editor.
    10. Click OK to close the SheetView Collection Editor.

    Using Code

    1. Define a currency cell by creating an instance of the CurrencyCellType class.
    2. Specify the formatting of a currency cell by setting the CurrencySymbol and other properties for the CurrencyCellType object.
    3. Assign the currency cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the CurrencyCellType object.

    Example

    This example creates a currency cell.

    C#
    Copy Code
    FarPoint.Win.Spread.CellType.CurrencyCellType currcell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
    currcell.CurrencySymbol = "US$";
    currcell.DecimalSeparator = ":";
    currcell.DecimalPlaces = 8;
    fpSpread1.ActiveSheet.Cells[1,1].CellType = currcell;
    
    VB
    Copy Code
    Dim currcell As New FarPoint.Win.Spread.CellType.CurrencyCellType()
    currcell.CurrencySymbol = "US$"
    currcell.DecimalSeparator = ":"
    currcell.DecimalPlaces = 8
    fpSpread1.ActiveSheet.Cells(1,1).CellType = currcell
    

    Using the Spread Designer

    1. Select the cell or cells in the work area.
    2. In the property list, in the Misc category, select CellType. From the drop-down list, choose the Currency cell type. Now expand the CellType property and various properties are available that are specific to this cell type. Select and set those properties as needed.

      Or right-click on the cell or cells and select Cell Type. From the list, select Currency. In the CellType editor, set the properties you need. Click Apply.

    3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
    See Also