Share via


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

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

The .NET Compact Framework 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.

Note

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

Example

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

Private Sub 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

End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
    ' Respond to changes, such as using  
    ' the updated value in your application.
End Sub
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

Other Resources

Windows Forms Controls in the .NET Compact Framework

Graphics and Drawing in the .NET Compact Framework