You can create a text cell that allows only text to be displayed or treats the contents of a cell as only text.
You can also specify if the text shows up as all lower case, upper case, or normal with the CharacterCasing property. The CharacterSet property allows you to specify numbers only, letters only, numbers and letters, or any ASCII characters.
You use the TextCellType class to set the text cell and its properties.
See Also
For more information on the properties and methods of this cell type, refer to the TextCellType class.
For more information on other editable cell types, refer to Working with Editable Cell Types.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet in which the cells appear.
- In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
- Select the cells for which you want to set the cell type.
- In the property list, select the CellType property and choose the Text cell type.
- Expand the list of properties under the CellType property. Select and set these specific properties as needed.
- Click OK to close the Cell, Column, and Row Editor.
- Click OK to close the SheetView Collection Editor.
Using Code
- Define the text cell by creating an instance of the TextCellType class.
- Create a message to display to the user when the entry is not valid.
- Assign the text cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the TextCellType object.
Example
C# | Copy Code |
---|---|
FarPoint.Win.Spread.CellType.TextCellType tcell = new FarPoint.Win.Spread.CellType.TextCellType(); tcell.CharacterCasing = CharacterCasing.Upper; tcell.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii; tcell.MaxLength = 30; tcell.Multiline = true; fpSpread1.ActiveSheet.Cells[0, 0].Text = "This is a text cell. "; fpSpread1.ActiveSheet.Cells[0, 0].CellType = tcell; |
VB | Copy Code |
---|---|
Dim tcell As New FarPoint.Win.Spread.CellType.TextCellType() tcell.CharacterCasing = CharacterCasing.Upper tcell.CharacterSet = FarPoint.Win.Spread.CellType.CharacterSet.Ascii tcell.MaxLength = 40 tcell.Multiline = True FpSpread1.ActiveSheet.Cells[0, 0].Text = "This is a text cell. FpSpread1.ActiveSheet.Cells(0, 0).CellType = tcell |
Using the Spread Designer
- Select the cell or cells in the work area.
- In the property list, in the Misc category, select CellType. From the drop-down list, choose the Text 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 Text. In the CellType editor, set the properties you need. Click Apply.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.