Ler en inglés

Compartir por


DateTimePickerFormat Enumeración

Definición

Especifica el formato de fecha y hora que muestra el control DateTimePicker.

C#
public enum DateTimePickerFormat
Herencia
DateTimePickerFormat

Campos

Nombre Valor Description
Custom 8

El control DateTimePicker muestra el valor de fecha y hora en un formato personalizado. Para obtener más información, vea CustomFormat.

Long 1

El control DateTimePicker muestra el valor de fecha y hora con el formato de fecha larga establecido por el sistema operativo del usuario.

Short 2

El control DateTimePicker muestra el valor de fecha y hora con el formato de fecha corta establecido por el sistema operativo del usuario.

Time 4

El control DateTimePicker muestra el valor de fecha y hora en el formato de hora establecido por el sistema operativo del usuario.

Ejemplos

En el ejemplo de código siguiente se muestra cómo inicializar un DateTimePicker objeto estableciendo en Format un DateTimePickerFormat valor . Para ejecutar este ejemplo, pegue el código siguiente en un formulario y llame InitializeDateTimePicker desde el constructor o Load el método de control de eventos del formulario.

C#

// Declare the DateTimePicker.
internal System.Windows.Forms.DateTimePicker DateTimePicker1;

private void InitializeDateTimePicker()
{
    // Construct the DateTimePicker.
    this.DateTimePicker1 = new System.Windows.Forms.DateTimePicker();

    //Set size and location.
    this.DateTimePicker1.Location = new System.Drawing.Point(40, 88);
    this.DateTimePicker1.Size = new System.Drawing.Size(160, 21);
    
    // Set the alignment of the drop-down MonthCalendar to right.
    this.DateTimePicker1.DropDownAlign = LeftRightAlignment.Right;

    // Set the Value property to 50 years before today.
    DateTimePicker1.Value = System.DateTime.Now.AddYears(-50);

    //Set a custom format containing the string "of the year"
    DateTimePicker1.Format = DateTimePickerFormat.Custom;
    DateTimePicker1.CustomFormat = "MMM dd, 'of the year' yyyy ";

    // Add the DateTimePicker to the form.
    this.Controls.Add(this.DateTimePicker1);
}

Comentarios

Esta enumeración la usan miembros como DateTimePicker.Format.

Nota

Los formatos de fecha y hora reales están determinados por la fecha, hora y configuración regional establecida en el sistema operativo del usuario.

Se aplica a

Produto Versións
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Consulte también