Spread Windows Forms 8.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, it is the general cell type that is assigned 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 put. The general cell type includes a formatter that takes the data entered by the user and coerces it into one of the known formats and data types. This frees the developer from worrying about setting cell types because the general cell type handle inputs of many kinds. The openness of the general cell can be restricted a bit if the developer wants to allow the user to enter data in any acceptable format, but wants it to be formatted and displayed in a specific way. To do this, the developer simply specifies a format string for the general cell type and the general formatter parses the user-entered data, but when the data is displayed, the developer-specified format is used rather than the format used by the end user.You could use the FormatString property. Here is an example in Visual Basic code:
Dim gnrlcell As New FarPoint.Win.Spread.GeneralCellType
gnrlcell.FormatString = "#,###.00"
FpSpread1.Sheets(0).Cells(1, 1).CellType = gnrlcell
If you want to customize how the general cell displays the data, you can work with the format string. The general cell type includes a formatter that takes the data entered by the user and coerces it into one of the known formats and data types. 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, you can 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.
For more information on the properties and methods of this cell type, refer to the GeneralCellType class.
Using the Properties Window
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.