How to: Use the DateTimePicker Class

How to: Use the DateTimePicker Class in the .NET Compact Framework 

The .NET Compact Framework version 2.0 supports the DateTimePicker class, but with only the following members:

Note that because OnValueChanged is provided, a derived class can use this method without having to connect an event handler delegate. For more information about using delegates, see Raising an Event.


The DateTimePicker for the Smartphone will be available in Windows Mobile version 5.0 software for Smartphone. Note that the control on the Smartphone does not have the up-down selector because values are selected with the navigation keys.


The following code example shows how you can configure a DateTimePicker control in the .NET Compact Framework.

private void SetupDateTimePicker()

   // Set the MinDate and MaxDate.
   dateTimePicker1.MinDate = new DateTime(1985, 6, 12);
   dateTimePicker1.MaxDate = DateTime.Today;

   // Set the format.
   dateTimePicker1.Format = DateTimePickerFormat.Short;

   // Define a custom format.
   dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";

   // If you want to use the custom format, change
   // DateTimePickerFormat.Short to DateTimePickerFormat.Custom.

   // Display the control with the up-down selector.
   dateTimePicker1.ShowUpDown = true;

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
 // Respond to changes, such as using
 // the updated value in your application.


Compiling the Code

This example requires references to the following namespaces:

See Also

Community Additions

© 2015 Microsoft