Cómo: Utilizar la clase DateTimePicker en .NET Compact Framework

Actualización: noviembre 2007

.NET Compact Framework admite la clase DateTimePicker, pero con sólo los miembros siguientes:

Observe que, dado que se proporciona OnValueChanged, una clase derivada puede utilizar este método sin tener que conectar un delegado del controlador de eventos. Para obtener más información sobre el uso de delegados, vea Provocar un evento.

Nota:

DateTimePicker para Smartphone estará disponible en el software Windows Mobile 5.0 para Smartphone. El control de Smartphone no tiene el selector de flechas porque los valores se seleccionan con las teclas de navegación.

Ejemplo

En el ejemplo de código siguiente se muestra cómo se puede configurar un control DateTimePicker en .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.

}

Compilar el código

Para este ejemplo se requieren referencias a los siguientes espacios de nombres:

Vea también

Otros recursos

Controles de formularios Windows Forms en .NET Compact Framework

Gráficos y dibujos en .NET Compact Framework