Articles in this section
Category / Section

How to detect the keys selection in the WinForms DateTimePicker ?

1 min read

Key selection

In the DateTimePickerAdv, key selection can be detected by handling the event named, PreviewKeyDown.  The following code example demonstrates the same.


private void dateTimePickerAdv1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
            //Checks whether the Enter key is pressed or not.
            if (e.KeyValue == (Char)Keys.Enter)
                MessageBox.Show("Enter key is pressed");


Private Sub dateTimePickerAdv1_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles dateTimePickerAdv1.PreviewKeyDown
            'Checks whether the Enter key is pressed or not.
            If e.KeyValue = Keys.Enter Then
                  MessageBox.Show("Enter key is pressed")
            End If
End Sub



I hope you enjoyed learning about how to detect the keys selection in the WinForms DateTimePicker.

You can refer to our WinForms DateTimePicker featuretour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied