Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Cell Types / Working with Editable Cell Types / Setting a GcTimeSpan Cell
In This Topic
    Setting a GcTimeSpan Cell
    In This Topic

    You can use the GcTimeSpan cell to display time values in a cell.

    GcTimeSpan Cell

    You can specify literals and a pattern for the characters the user is allowed to enter.

    The following table lists the characters you can use to create a pattern:

    Keyword Description
    d Represents the day field.
    h Represents the hour field.
    m Represents the minute field.
    s Represents the second field.

    You can use the following classes with the GcTimeSpan cell to create display fields (literals) and input fields:

    For a complete list of properties and methods for the GcTimeSpan cell, refer to the GcTimeSpanCellType class.

    Using Code

    1. Define the cell by creating an instance of the GcTimeSpanCellType class.
    2. Set the pattern or literal characters.
    3. Set properties for the class.
    4. 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 GcTimeSpan object.

    Example

    This example creates a GcTimeSpan cell.

    C#
    Copy Code
    GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType GC = new
    GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType();
    GC.AcceptsArrowKeys = FarPoint.Win.SuperEdit.AcceptsArrowKeys.AllArrows;
    GC.EditMode = GrapeCity.Win.Spread.InputMan.CellType.EditMode.Overwrite;
    GC.ExitOnLastChar = true;
                    
    GC.Fields.Clear();
    GC.Fields.AddRange("d.hh:mm:ss,7,.,,,-,");
    GC.DisplayFields.Clear();
    GC.DisplayFields.AddRange("d.hh:mm:ss,7,.,,,-,");
    GC.DefaultActiveField = GC.Fields[1];
                    
    GC.FocusPosition = GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorFocusCursorPosition.SelectAll;
    GC.MaxMinBehavior = GrapeCity.Win.Spread.InputMan.CellType.MaxMinBehavior.Clear;
    GC.NegativeColor = Color.Chocolate;
    GC.PaintByControl = true;
    GC.ShowRecommendedValue = true;
                    
    GC.SideButtons.Add(new GrapeCity.Win.Spread.InputMan.CellType.SpinButtonInfo());
    GC.Spin.AllowSpin = true;
    GC.Spin.Increment = 1;
    GC.Spin.SpinOnKeys = true;
    GC.Spin.SpinOnWheel = true;
    GC.Spin.Wrap = true;
                    
    GC.UseNegativeColor = true;
    GC.ValidateMode = GrapeCity.Win.Spread.InputMan.CellType.ValidateMode.ValidateNone;
    GC.ValueSign = GrapeCity.Win.Spread.InputMan.CellType.ValueSignControl.Positive;
    GC.UseSpreadDropDownButtonRender = true;
                    
    fpSpread1.ActiveSheet.Cells[0, 0].CellType = GC;
    
    VB
    Copy Code
    Dim GC As New GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType()
    GC.AcceptsArrowKeys = FarPoint.Win.SuperEdit.AcceptsArrowKeys.AllArrows
    GC.EditMode = GrapeCity.Win.Spread.InputMan.CellType.EditMode.Overwrite
    GC.ExitOnLastChar = True
                    
    GC.Fields.Clear()
    GC.Fields.AddRange("d.hh:mm:ss,7,.,,,-,")
    GC.DisplayFields.Clear()
    GC.DisplayFields.AddRange("d.hh:mm:ss,7,.,,,-,")
    GC.DefaultActiveField = GC.Fields(1)
                    
    GC.FocusPosition = GrapeCity.Win.Spread.InputMan.CellType.FieldsEditorFocusCursorPosition.SelectAll
    GC.MaxMinBehavior = GrapeCity.Win.Spread.InputMan.CellType.MaxMinBehavior.Clear
    GC.NegativeColor = Color.Chocolate
    GC.PaintByControl = True
    GC.ShowRecommendedValue = True
                    
    GC.SideButtons.Add(New GrapeCity.Win.Spread.InputMan.CellType.SpinButtonInfo())
    GC.Spin.AllowSpin = True
    GC.Spin.Increment = 1
    GC.Spin.SpinOnKeys = True
    GC.Spin.SpinOnWheel = True
    GC.Spin.Wrap = True
                    
    GC.UseNegativeColor = True
    GC.ValidateMode = GrapeCity.Win.Spread.InputMan.CellType.ValidateMode.ValidateNone
    GC.ValueSign = GrapeCity.Win.Spread.InputMan.CellType.ValueSignControl.Positive
    GC.UseSpreadDropDownButtonRender = True
                    
    fpSpread1.ActiveSheet.Cells(0, 0).CellType = GC
    

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