I’ve made a custom datepicker control to allow input of short dates (ex. “010111”, “01012011” or “01-01-2011”)
Somehow the events won’t get triggered.
Public Class DatePicker
Inherits System.Windows.Controls.DatePicker
Private Sub DatePicker_PreviewTextInput(sender As Object, e As Windows.Input.TextCompositionEventArgs) Handles Me.PreviewTextInput
If Me.Text.Length >= 6 Then
Dim strInput As String = Me.Text.Trim
Dim dtInput As Date = Nothing
Select Case strInput.Length
Case Is = 6
dtInput = New Date(CInt(Mid(strInput, 5, 2)), CInt(Mid(strInput, 3, 2)), CInt(Mid(strInput, 1, 2)))
Case Is = 8
dtInput = New Date(CInt(Mid(strInput, 5, 4)), CInt(Mid(strInput, 3, 2)), CInt(Mid(strInput, 1, 2)))
Case Is >= 10
dtInput = New Date(CInt(Mid(strInput, 7, 4)), CInt(Mid(strInput, 4, 2)), CInt(Mid(strInput, 1, 2)))
End Select
Me.SelectedDate = dtInput
End If
e.Handled = True
End Sub
End Class
Ok i resolved it a different way.