DateTimePickerFormat Výčet
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Určuje formát data a času, který se zobrazí DateTimePicker ovládacím prvku.
public enum class DateTimePickerFormat
public enum DateTimePickerFormat
type DateTimePickerFormat =
Public Enum DateTimePickerFormat
- Dědičnost
Pole
| Name | Hodnota | Description |
|---|---|---|
| Long | 1 | Ovládací DateTimePicker prvek zobrazí hodnotu data a času v dlouhém formátu data nastaveném operačním systémem uživatele. |
| Short | 2 | Ovládací DateTimePicker prvek zobrazí hodnotu data a času v krátkém formátu data nastaveném operačním systémem uživatele. |
| Time | 4 | Ovládací DateTimePicker prvek zobrazí hodnotu data a času ve formátu času nastaveném operačním systémem uživatele. |
| Custom | 8 | Ovládací DateTimePicker prvek zobrazí hodnotu data a času ve vlastním formátu. Další informace najdete na webu CustomFormat. |
Příklady
Následující příklad kódu ukazuje inicializaci DateTimePicker objektu nastavením Format na DateTimePickerFormat hodnotu. Chcete-li spustit tento příklad, vložte následující kód do formuláře a volání InitializeDateTimePicker z konstruktoru formuláře nebo Load metody zpracování událostí.
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
Poznámky
Tento výčet používají členové, například DateTimePicker.Format.
Note
Skutečné formáty data a času jsou určeny datem, časem a místním nastavením nastaveným v operačním systému uživatele.