In this article I will explain with an example, how to use Calendar in Windows Forms (WinForms) Application using C# and VB.Net.
The following Form consists of a DateTimePicker control and a Button. The Button has been assigned a Click event handler.
Fetching the value of the Selected Date
When the Submit Button is clicked, following event handler is executed.
Inside this event handler, the value of the Selected Date is fetched and displayed using MessageBox.
private void btnSubmit_Click(object sender, EventArgs e)
DateTime dt = Convert.ToDateTime(dateTimePicker1.Value);
MessageBox.Show("Selected Date: " + dt.ToString());
Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim dt As DateTime = Convert.ToDateTime(dateTimePicker1.Value)
MessageBox.Show("Selected Date: " & dt.ToString())