This is a migrated thread and some comments may be shown as answers.

Typing Date

2 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 05 Oct 2015, 09:08 AM

Having complains from users when typing in a date for a GridViewDateTimeColumn

On the RadDateTimePicker there is an option called AutoSelectNextPart  (see code below)

Can this be used with the gridview, GridViewDateTimeColumn?

Many Thanks

 

Dim provider As MaskDateTimeProvider = TryCast(Me.dtpContractSigned.DateTimePickerElement.TextBoxElement.Provider, MaskDateTimeProvider)
provider.AutoSelectNextPart = True

2 Answers, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 06 Oct 2015, 06:19 AM
Hi Mark,

Thank you for contacting us. 

In Q2 2014 (2014.2.617) we added the AutoSelectNextPart property to the MaskDateTimeProvider. You can set the AutoSelectNextPart property to true in the CellEditorInitialized event handler for GridViewDateTimeColumn. Please refer to the code snippet below:
Partial Public Class Form1
Inherits Form
    Public Sub New()
        InitializeComponent()
        Dim dateTimeColumn As New GridViewDateTimeColumn()
        dateTimeColumn.Name = "OrderDate"
        dateTimeColumn.HeaderText = "OrderDate"
        dateTimeColumn.FieldName = "OrderDate"
        dateTimeColumn.Width = 200
        dateTimeColumn.Format = DateTimePickerFormat.[Custom]
        dateTimeColumn.CustomFormat = "MM/dd/yyyy"
        dateTimeColumn.FormatString = "{0:MM/dd/yyyy}"
        RadGridView1.MasterTemplate.Columns.Add(dateTimeColumn)
 
        For i As Integer = 0 To 4
            Me.radGridView1.Rows.Add(DateTime.Now.AddDays(i))
        Next
        Me.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
 
        AddHandler Me.radGridView1.CellEditorInitialized, AddressOf radGridView1_CellEditorInitialized
    End Sub
 
    Private Sub radGridView1_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs)
        If TypeOf e.ActiveEditor Is RadDateTimeEditor Then
            Dim editor As RadDateTimeEditor = TryCast(e.ActiveEditor, RadDateTimeEditor)
            Dim element As RadDateTimeEditorElement = TryCast(editor.EditorElement, RadDateTimeEditorElement)
            Dim provider As MaskDateTimeProvider = TryCast(element.TextBoxElement.Provider, MaskDateTimeProvider)
            provider.AutoSelectNextPart = True
        End If
    End Sub
End Class

Hope this will help you. Let me know if you have any other questions.

Regards,
Ralitsa
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 06 Oct 2015, 07:10 AM

Many Thanks.

Mark

Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Mark
Top achievements
Rank 1
Share this question
or