Current date in DateTimePickerAdv in Windows Forms

28 Apr 20211 minute to read

This page explains How to navigate to current date in DateTimePickerAdv and more details.

How to navigate to current date in DateTimePickerAdv ?

In DateTimePicker, we can navigate to current date by using the NavigateToCurrentDate method.

For example, it is possible to select current date on Enter key press and the following code illustrates the same.

void dateTimePickerAdv1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
   // On pressing Enter key, date time picker navigates to current date.
   if(e.KeyData== Keys.Enter)
    this.dateTimePickerAdv1.NavigateToCurrentDate(true);
}
Private Sub dateTimePickerAdv1_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs)
   ' On pressing Enter key, date time picker navigates to current date.
   If e.KeyData= Keys.Enter Then
    Me.dateTimePickerAdv1.NavigateToCurrentDate(True)
   End If
End Sub