Spread Windows Forms 12.0 Product Documentation
Setting a GcDateTime Cell
Spread Windows Forms 12.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Editable Cell Types > Setting a GcDateTime Cell

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.

You can specify the type of drop-down to display with the DropDownType property. The drop-down picker type is easier to use in a touch environment.

For a complete list of properties, see the GcDateTimeCellType 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 GcDateTime 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 text cell by creating an instance of the GcDateTimeCellType class.
  2. Set properties for the class.
  3. 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.

Example

This example creates a GcDateTime cell.

C#
Copy Code
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[0].Cells[0, 0].CellType = inputcell;
VB
Copy Code
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

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

  3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.