How to Auto-Select initial field in the DateTimePickerAdv once it is focused?
The null value of the DateTimePickerAdv is not set, by default. It can be set to DateTimePickerAdv by enabling the property, IsNullDate. When Date value is set as null date, the property NullModeKeyReset is set to ArrowKeys, by default.
The NullModeKeyReset property helps you define the keyboard navigation of the DateTimePickerAdv. When the date value is changed by keyboard navigation, the field of the DateTimePickerAdv changes continuously.
It is possible to AutoSelect the initial field or date value once it is focused by using its property named ResetSelectionOnFocus.
The following code example demonstrates the same.
C#
//Sets the selected value as Null. this.dateTimePickerAdv1.IsNullDate = true; //Gets or sets the keys that toggles off null date. this.dateTimePickerAdv1.NullModeKeyReset = NullModeKeyReset.NumericKeys; //Focuses the DateTimePickerAdv selection on the first field. this.dateTimePickerAdv1.ResetSelectionOnFocus = true;
VB
'Sets the selected value as Null. Me.dateTimePickerAdv1.IsNullDate = True 'Gets or sets the keys that toggles off null date. Me.dateTimePickerAdv1.NullModeKeyReset = NullModeKeyReset.NumericKeys 'Focuses the DateTimePickerAdv selection on the first field. Me.dateTimePickerAdv1.ResetSelectionOnFocus = True
Figure 1: Before selecting the date
Figure 2: After selecting the date
I hope you enjoyed learning about how to Auto-Select the initial field in the WinForms DateTimePickerAdv.
You can refer to our WinForms DateTimePicker feature tour 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 WinForms DateTimePicker 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!