Allow a two digit in year part of RadDateTimePicker

2 posts, 0 answers
  1. Dhaval
    Dhaval avatar
    2 posts
    Member since:
    Sep 2015

    Posted 19 Apr 2016 Link to this post

    I am facing issue with RadDateTimePicker.Is it possible to enter only two digit in the year part like if i enter 16 than it will be consider as 2016 not to enter 2016? If i enter 16 than it will consider as 2016 and if i enter 2016 than it will consider same 2016. please check below code i used for RadDateTimePicker

    Public Sub New()
            Me.CustomFormat = "MM/dd/yyyy"
            AddHandler Me.LostFocus, AddressOf radDateTimePicker1_LostFocus
            Me.Font = New System.Drawing.Font("Tahoma", 8.25!)
            Me.Format = System.Windows.Forms.DateTimePickerFormat.Custom
            Me.NullText = "  /   /"
            Me.Size = New System.Drawing.Size(80, 19)
            Me.Value = New Date(CType(0, Long))
            CType(Me.DateTimePickerElement.GetCurrentBehavior(), RadDateTimePickerCalendar).Calendar.FirstDayOfWeek = FirstDayOfWeek.Monday
            CType(Me.DateTimePickerElement.TextBoxElement.Provider, MaskDateTimeProvider).AutoSelectNextPart = True
        End Sub

    Private Sub radDateTimePicker1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
                If (Me.Value = "#12:00:00 AM#" Or Date.MinValue = Me.Value.ToShortDateString() Or Me.Value.Year <= 1900) Then
                    Me.NullableValue = Date.MinValue
                    Me.NullText = "  /  /"
                End If
            Catch ex As Exception
            End Try
        End Sub
  2. Hristo
    Hristo avatar
    1522 posts

    Posted 20 Apr 2016 Link to this post

    Hello Dhaval,

    Thank you for writing.

    In order to achieve this task, you would need to use the FreeFormDateTime mask. Please check this documentation article providing additional information: Free Form Date Time Parsing.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top