GrapeCity MultiRow Windows Forms Documentation
Automatically Confirm Initial Value as Input Value (DateTimePickerCell)

By default the current date and time are displayed as the initial values when the date time picker cell is being edited. This initial value is not saved as the cell value until it is explicitly entered as a cell value. This behavior is due to the DateTimePickerEditingControl, which inherits from the System.Windows.Forms.DateTimePicker control. To apply the initial value shown in the date time picker cell as the input value, you will need to write code to confirm input in the date time picker cell, which holds the initial value, once its editing completes.

Using Code

This example applies the initial value.

[VB]

Imports GrapeCity.Win.MultiRow

Private Sub GcMultiRow1_CellEndEdit(ByVal sender As System.Object, ByVal e As CellEndEditEventArgs) Handles GcMultiRow1.CellEndEdit
    Dim gcMultiRow As GcMultiRow = TryCast(sender, GcMultiRow)
    Dim currentCell As Cell = gcMultiRow.Rows(e.RowIndex).Cells(e.CellIndex)
    
    If e.EditCanceled = False Then
        If TypeOf currentCell Is DateTimePickerCell Then
            If currentCell.Value Is Nothing Then
                currentCell.Value = Date.Now
            End If
        End If
    End If
End Sub

[CS]

using GrapeCity.Win.MultiRow;

private void gcMultiRow1_CellEndEdit(object sender, CellEndEditEventArgs e)
{
    GcMultiRow gcMultiRow = sender as GcMultiRow;
    Cell currentCell = gcMultiRow.Rows[e.RowIndex].Cells[e.CellIndex];
    
    if (e.EditCanceled == false)
    {
        if (currentCell is DateTimePickerCell)
        {
            if (currentCell.Value == null)
            {
                currentCell.Value = DateTime.Now;
            }
        }
    }
}
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options