Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Esta página es específica de
Microsoft Visual Studio 2008/.NET Framework 3.5

Hay además otras versiones disponibles para:
Biblioteca de clases de .NET Framework
DateTimePickerFormat (Enumeración)

Actualización: noviembre 2007

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

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Visual Basic (Declaración)
Public Enumeration DateTimePickerFormat
Visual Basic (Uso)
Dim instance As DateTimePickerFormat
C#
public enum DateTimePickerFormat
Visual C++
public enum class DateTimePickerFormat
J#
public enum DateTimePickerFormat
JScript
public enum DateTimePickerFormat
Nombre de miembroDescripción
yxd0x8sd.CFW(es-es,VS.90).gifLongEl control DateTimePicker muestra el valor de fecha y hora con el formato de fecha larga establecido por el sistema operativo del usuario.
yxd0x8sd.CFW(es-es,VS.90).gifShortEl control DateTimePicker muestra el valor de fecha y hora con el formato de fecha corta establecido por el sistema operativo del usuario.
yxd0x8sd.CFW(es-es,VS.90).gifTimeEl control DateTimePicker muestra el valor de fecha y hora en el formato de hora establecido por el sistema operativo del usuario.
yxd0x8sd.CFW(es-es,VS.90).gifCustomEl control DateTimePicker muestra el valor de fecha y hora en un formato personalizado.

Miembros como DateTimePicker..::.Format utilizan esta enumeración.

yxd0x8sd.alert_note(es-es,VS.90).gifNota:

La fecha, la hora y la configuración regional establecida en el sistema operativo del usuario determinan los formatos de fecha y hora reales.

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

Visual Basic
' 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
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);
    }
Visual C++
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 );
   }
J#
// Declare the DateTimePicker.
private System.Windows.Forms.DateTimePicker dateTimePicker1;

private void InitializeDateTimePicker()
{
    // Construct the DateTimePicker.
    this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
    //Set size and location.
    this.dateTimePicker1.set_Location(new System.Drawing.Point(40, 88));
    this.dateTimePicker1.set_Size(new System.Drawing.Size(160, 21));
    // Set the alignment of the drop-down MonthCalendar to right.
    this.dateTimePicker1.set_DropDownAlign(LeftRightAlignment.Right);
    // Set the Value property to 50 years before today.
    dateTimePicker1.set_Value(System.DateTime.get_Now().AddYears(-50));
    //Set a custom format containing the string "of the year"
    dateTimePicker1.set_Format(DateTimePickerFormat.Custom);
    dateTimePicker1.set_CustomFormat("MMM dd, 'of the year' yyyy ");
    // Add the DateTimePicker to the form.
    this.get_Controls().Add(this.dateTimePicker1);
} //InitializeDateTimePicker

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 3.5, 2.0
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker