You can use the GcDateTime cell to display date and time values. The GcDateTime cell allows the user to pick a date from a calendar drop-down or type in the cell. This cell is part of the GrapeCity.Win.PluginInputMan assembly.
The GcDateTime cell supports different calendar styles from the DateTime cell. You can specify which fields to display with the DisplayFields property.
You can specify the focus position when the cell gets focus with the FocusPosition property and you can specify whether focus leaves the cell after typing the last character in the date value with the ExitOnLastChar property.
You can use the ShortcutKeys property to map keys to actions for the GcDateTime and GcTextBox cells. In edit mode, these shortcut keys have precedence over the Spread input maps. The cell uses the Spread input maps when not in edit mode.
For a complete list of properties, see the GcDateTimeCellType class.
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 GcDateTime 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.
- Define the text cell by creating an instance of the GcDateTimeCellType class.
- Set properties for the class.
- Assign the cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the GcDateTimeCellType object.
This example creates a GcDateTimeCellType cell.
|GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType inputcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
inputcell.EditMode = GrapeCity.Win.Spread.InputMan.CellType.EditMode.Overwrite;
fpSpread1.Sheets.Cells[0, 0].CellType = inputcell;
|Dim inputcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType
inputcell.EditMode = GrapeCity.Win.Spread.InputMan.CellType.EditMode.Overwrite
FpSpread1.Sheets(0).Cells(0, 0).CellType = inputcell
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 GcDateTime. 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.