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

    The general cell is the default cell type for the cells in the sheets. Unless you specify another cell type, the component assigns the general cell type to the cells. The general cell can be used as is for entering text or numbers where formatting is not critical or the type of data is not tied to a specific data type. For specific cell types where formatting is important, see the CurrencyCellType, DateTimeCellType, NumberCellType, and PercentCellType cells.

    You use the GeneralCellType class to set the general cell and its properties.

    With the general cell you can format the displayed values regardless of the user input. The general cell type includes a formatter that takes the data entered by the user and assigns it one of the known formats and data types. Therefore, you need not worry about setting cell types because the general cell type handles inputs of many kinds.

    The openness of the general cell can be restricted if you want to allow the user to enter data in any acceptable format, but want it to be formatted and displayed in a specific way. To allow the user to enter data in any acceptable format and format and display the data in a specific way, adjust the formatter for the general cell type. To do this, specify a format string for the general cell and the general formatter parses the user-entered data, but when the data is displayed, your custom format is used rather than the format used by the end user. You can use the FormatString property. Here is an example:

    Visual Basic
    Copy Code
    Dim gnrlcell As New FarPoint.Win.Spread.GeneralCellType
    gnrlcell.FormatString = "#,###.00"
    fpSpread1.Sheets(0).Cells(1, 1).CellType = gnrlcell
    

    For more information on the properties and methods of this cell type, refer to the GeneralCellType 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 General 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 the general cell by creating an instance of the GeneralCellType class.
    2. Set properties for the class.
    3. Assign the general cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the GeneralCellType object.

    Example

    This example sets a cell to be a general cell.

    C#
    Copy Code
    FarPoint.Win.Spread.CellType.GeneralCellType gnrlcell = new FarPoint.Win.Spread.CellType.GeneralCellType();
    fpSpread1.ActiveSheet.Cells[1, 1].CellType = gnrlcell;
    ;
    
    VB
    Copy Code
    Dim gnrlcell As New FarPoint.Win.Spread.CellType.GeneralCellType()
    fpSpread1.ActiveSheet.Cells(1, 1).CellType = gnrlcell
    

    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 General 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 General. 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