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

Allow a two digit in year part of RadDateTimePicker

1 Answer 73 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Dhaval
Top achievements
Rank 1
Dhaval asked on 19 Apr 2016, 08:46 AM
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.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)
        Try
            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
 

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 20 Apr 2016, 12:33 PM
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.

Regards,
Hristo Merdjanov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Dhaval
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or