You can create a GcDateTime cell that displays date and time values. This can be useful if you want to restrict the type of data the user can type in the cell. The GcDateTimeCellType is part of the GrapeCity.Win.PluginInputMan assembly. The GcDateTime cell allows the user to pick a date from a calendar drop-down or type in the cell. The GcDateTime cell supports different calendar styles. You can set colors and styles with the DropDownCalendar class. 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 cell. 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. The GcDateTimeCellType class has the following properties:
Property
Description
AcceptsArrowKeys
Gets or sets how arrow keys are processed by the edit control. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
AcceptsCrLf
Gets or sets a value that indicates how to process the CrLf characters when copying, cutting, or pasting the string.
AlternateText
Gets the alternate text of the GcDateTimeCellType object.
BackgroundImage
Gets or sets the background image for the cell. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
ClipContent
Gets or sets how data is copied to the Clipboard. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorControlCellType)
DefaultActiveField
Gets or sets the default active field of the cell.
DisplayFields
Gets the display fields of the GcDateTimeCellType object.
DropDown
Gets the drop-down settings for the drop-down function.
DropDownCalendar
Gets the settings for the drop-down calendar.
DropDownPicker
Gets the settings for the drop-down picker.
EditMode
Gets or sets the edit mode of the control. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
ExcelExportFormat
Overridden. Gets or sets the excel export format.
ExitOnLastChar
Gets or sets whether the next control in the tab order receives the focus as soon as the control is filled with the last character. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
Fields
A GrapeCity.Win.Spread.InputMan.CellType.DateFieldCollection that represents the items in the GcDateTime object.
FieldsEditMode
Gets or sets the fields edit mode.
FocusPosition
Gets or sets the initial cursor position when the editor gets focus.
MaxDate
Gets or sets the maximum allowable value when changing the field or value of the control using the spin setting.
MaxMinBehavior
Gets or sets the behavior when the new input value is outside of GcDateTime.MinDate and GcDateTime.MaxDate.
MinDate
Gets or sets the minimum allowable value when changing the field or value of the control using the spin setting.
PaintByControl
Gets or sets a value that indicates how to paint the cell. If true, the cell uses the inner control's painting to paint the cell, in this case, the cell paints exactly the same as the editing control. All settings of the cell such as fields with different styles are shown when painting the cell. The cell's paint performance is slow if painting by the control, rather than painting the string directly. Also, the text in the cell cannot be selected when exporting to pdf. If false, performance is good but some settings do not take effect.
PromptChar
Gets or sets the character used as a prompt for input. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorControlCellType)
ReadOnly
Gets or sets a value that indicates whether this control is read-only. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
RecommendedValue
Gets or sets the recommended value.
ShortcutKeys
Gets the InputMan EditingControl's shortcuts. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
ShowLiterals
Gets or sets whether to display the literals during user entry. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorControlCellType)
ShowRecommendedValue
Gets or sets a value that indicates whether to show the recommended value.
ShowTouchToolBar
Gets or sets how to show the InputManCellTypeBase.TouchToolBar. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
SideButtons
Gets a collection of side buttons.
Spin
Gets the spin function settings.
Static
Gets or sets whether the cell is static, which prohibits user interaction. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase
SubEditor
Gets or sets the subeditor. (Inherited from FarPoint.Win.Spread.CellType.BaseCellType)
TabAction
Gets or sets whether the tab key moves the focus between controls or between fields within the control. (Inherited fromGrapeCity.Win.Spread.InputMan.CellType.FieldsEditorControlCellType)
TouchContextMenuScale
Gets or sets the factor applied to the context menu item's height while the context menu is open when using touch. (Inherited fromGrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
TouchToolBar
Gets the displayed InputManCellTypeBase.TouchToolBar when using a touch operation. (Inherited from GrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
UseSpreadDropDownButtonRender
Gets or sets a value that indicates whether to paint the drop-down button with the spread drop-down button renderer. (Inherited fromGrapeCity.Win.Spread.InputMan.CellType.InputManCellTypeBase)
ValidateMode
Gets or sets the validation mode during control input.
This example uses the ShortcutKeys property. Use the Tab key to put a date in the cell while the cell is in edit mode. The following image displays the list of actions that you can use.
C#
GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType inputcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
inputcell.ShortcutKeys.Add(System.Windows.Forms.Keys.Tab, "SetNow");
fpSpread1.Sheets[0].Cells[0, 0].CellType = inputcell;
VB
Dim inputcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
inputcell.ShortcutKeys.Add(System.Windows.Forms.Keys.Tab, "SetNow")
FpSpread1.Sheets(0).Cells(0, 0).CellType = inputcell
This example sets colors for the calendar and displays a border around today’s date. Drop-down Calendar C#
GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType inputcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
inputcell.DropDownCalendar.BackColor = Color.Aquamarine;
inputcell.DropDownCalendar.TodayMarkColor = Color.Firebrick;
inputcell.DropDownCalendar.BorderStyle = BorderStyle.FixedSingle;
inputcell.DropDownCalendar.ShowTodayMark = true;
fpSpread1.Sheets[0].Cells[0, 0].CellType = inputcell;
fpSpread1.Sheets[0].Columns[0].Width = 100;
VB
Dim inputcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
inputcell.DropDownCalendar.BackColor = Color.Aquamarine
inputcell.DropDownCalendar.TodayMarkColor = Color.Firebrick
inputcell.DropDownCalendar.BorderStyle = BorderStyle.FixedSingle
inputcell.DropDownCalendar.ShowTodayMark = True
FpSpread1.Sheets(0).Cells(0, 0).CellType = inputcell
FpSpread1.Sheets(0).Columns(0).Width = 100
This example creates a custom format for the GcDateTime cell. Custom Format C#
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo fvalue = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo();
fvalue.BackColor = Color.Lavender;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthFieldInfo mvalue = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthFieldInfo();
mvalue.BackColor = Color.Azure;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearFieldInfo yvalue = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearFieldInfo();
yvalue.BackColor = Color.Crimson;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralFieldInfo eday = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralFieldInfo();
eday.Text = "/";
GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType inputcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayDisplayFieldInfo day = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayDisplayFieldInfo();
day.ShowLeadingZero = true;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthDisplayFieldInfo month = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthDisplayFieldInfo();
month.ShowLeadingZero = true;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearDisplayFieldInfo year = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearDisplayFieldInfo();
year.ShowLeadingZero = true;
GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralDisplayFieldInfo lday = new GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralDisplayFieldInfo();
lday.Text = "/";
inputcell.DisplayFields.Add(month);
inputcell.DisplayFields.Add(lday);
inputcell.DisplayFields.Add(day);
inputcell.DisplayFields.Add(lday);
inputcell.DisplayFields.Add(year);
inputcell.Fields.Clear();
inputcell.Fields.Add(mvalue);
inputcell.Fields.Add(eday);
inputcell.Fields.Add(fvalue);
inputcell.Fields.Add(eday);
inputcell.Fields.Add(yvalue);
fpSpread1.Sheets[0].Cells[1, 1].CellType = inputcell;
VB
Dim fvalue As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayFieldInfo()
fvalue.BackColor = Color.Lavender
Dim mvalue As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthFieldInfo()
mvalue.BackColor = Color.Azure
Dim yvalue As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearFieldInfo()
yvalue.BackColor = Color.Crimson
Dim eday As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralFieldInfo()
eday.Text = "/"
Dim inputcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
Dim day As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateDayDisplayFieldInfo()
day.ShowLeadingZero = True
Dim month As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateMonthDisplayFieldInfo()
month.ShowLeadingZero = True
Dim year As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateYearDisplayFieldInfo()
year.ShowLeadingZero = True
Dim lday As New GrapeCity.Win.Spread.InputMan.CellType.Fields.DateLiteralDisplayFieldInfo()
lday.Text = "/"
inputcell.DisplayFields.Add(month)
inputcell.DisplayFields.Add(lday)
inputcell.DisplayFields.Add(day)
inputcell.DisplayFields.Add(lday)
inputcell.DisplayFields.Add(year)
inputcell.Fields.Clear()
inputcell.Fields.Add(mvalue)
inputcell.Fields.Add(eday)
inputcell.Fields.Add(fvalue)
inputcell.Fields.Add(eday)
inputcell.Fields.Add(yvalue)
FpSpread1.Sheets(0).Cells(1, 1).CellType = inputcell