Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Editable Cell Types > Setting a General Cell |
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.
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 |
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.