Category / Section
How to retrieve selected date in DateTimePickerAdv?
1 min read
In DateTimePickerAdv, the selected value can be retrieved by following below steps.
- The date selection of the calendar popup can be detected by handling the event named “DateSelected” of the Calendar property in DateTimePickerAdv.
- The selected value can be retrieved by using the property named “Value” in DateTimePickerAdv.
The following code example demonstrates the same.
C#
//Occurs on user makes the date selection. this.dateTimePickerAdv1.Calendar.DateSelected += Calendar_DateSelected; void Calendar_DateSelected(object sender, EventArgs e) { label1.Text = this.dateTimePickerAdv1.Value.ToString(); }
VB
'Occurs on user makes the date selection. AddHandler Me.dateTimePickerAdv1.Calendar.DateSelected, AddressOf Calendar_DateSelected Private Sub Calendar_DateSelected(ByVal sender As Object, ByVal e As EventArgs) label1.Text = Me.dateTimePickerAdv1.Value.ToString() End Sub
Note:
The DateSelected event will be raised when selecting the date using the mouse click.
Figure 1: The selected value of the DateTimePickerAdv.
Sample Links: