DateTimePickerFormat DateTimePickerFormat DateTimePickerFormat DateTimePickerFormat Enum

Definición

Especifica el formato de fecha y hora que muestra el control DateTimePicker.Specifies the date and time format the DateTimePicker control displays.

public enum class DateTimePickerFormat
public enum DateTimePickerFormat
type DateTimePickerFormat = 
Public Enum DateTimePickerFormat
Herencia
DateTimePickerFormatDateTimePickerFormatDateTimePickerFormatDateTimePickerFormat

Campos

Custom Custom Custom Custom 8

El control DateTimePicker muestra el valor de fecha y hora en un formato personalizado.The DateTimePicker control displays the date/time value in a custom format. Para obtener más información, vea CustomFormat.For more information, see CustomFormat.

Long Long Long 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.The DateTimePicker control displays the date/time value in the long date format set by the user's operating system.

Short Short Short 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.The DateTimePicker control displays the date/time value in the short date format set by the user's operating system.

Time Time Time Time 4

El control DateTimePicker muestra el valor de fecha y hora en el formato de hora establecido por el sistema operativo del usuario.The DateTimePicker control displays the date/time value in the time format set by the user's operating system.

Ejemplos

En el ejemplo de código siguiente se DateTimePicker muestra cómo inicializar un objeto DateTimePickerFormat estableciendo en un valor. FormatThe following code example demonstrates initializing a DateTimePicker object by setting the Format to a DateTimePickerFormat value. Para ejecutar este ejemplo, pegue el siguiente código en un formulario y InitializeDateTimePicker llame a desde el constructor del Load formulario o el método de control de eventos.To run this example paste the following code in a form and call InitializeDateTimePicker from the form's constructor or Load event-handling method.

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

private:
   void InitializeDateTimePicker()
   {
      // Construct the DateTimePicker.
      this->DateTimePicker1 = gcnew System::Windows::Forms::DateTimePicker;
      
      //Set size and location.
      this->DateTimePicker1->Location = System::Drawing::Point( 40, 88 );
      this->DateTimePicker1->Size = 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 );
   }

// 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);
}

' Declare the DateTimePicker.
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker


Private Sub InitializeDateTimePicker()

    ' Construct the DateTimePicker.
    Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker

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

    ' Set the Value property to 50 years before today.
    DateTimePicker1.Value = (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.
    Me.Controls.Add(Me.DateTimePicker1)
End Sub

Comentarios

Esta enumeración la usan miembros como DateTimePicker.Format.This enumeration is used by members such as DateTimePicker.Format.

Nota

Los formatos de fecha y hora reales se determinan en función de la fecha, la hora y la configuración regional establecida en el sistema operativo del usuario.The actual date/time formats are determined by the date, time, and regional settings set in the user's operating system.

Se aplica a

Consulte también: