In this article I will explain with an example, how to get only Date from DateTimePicker (Calendar) in Windows Forms (WinForms) Application using C# and VB.Net.
Form Design
The following form consists of a DateTimePicker and a Button control.
Getting only Date from DateTimePicker in Windows Forms using C# and VB.Net
The following event handler is executed when Submit button is clicked.
Inside this event handler, the selected date is displayed in Message Box.
C#
private void OnSubmit(object sender, EventArgs e)
{
DateTime dt = Convert.ToDateTime(dateTimePicker1.Value);
MessageBox.Show("Selected Date: " + dt.ToShortDateString());
}
VB.Net
Private Sub OnSubmit(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim dt As DateTime = Convert.ToDateTime(dateTimePicker1.Value)
MessageBox.Show("Selected Date: " & dt.ToShortDateString())
End Sub
Screenshot
Demo
Downloads