DateTimePicker.Value Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur nilai tanggal/waktu yang ditetapkan ke kontrol.
public:
property DateTime Value { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Bindable(true)]
public DateTime Value { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Value : DateTime with get, set
Public Property Value As DateTime
Nilai Properti
Nilai DateTime yang ditetapkan ke kontrol.
- Atribut
Pengecualian
Contoh
Contoh kode berikut menunjukkan cara menggunakan Value properti untuk mengambil nilai tanggal saat ini. Pertama, contoh menampilkan Value properti . Contoh kemudian menaikkan Value properti satu hari dan menampilkan nilai properti lagi.
public:
MyClass()
{
// Create a new DateTimePicker
DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
array<Control^>^ myClassControls = {dateTimePicker1};
Controls->AddRange( myClassControls );
MessageBox::Show( dateTimePicker1->Value.ToString() );
dateTimePicker1->Value = DateTime::Now.AddDays( 1 );
MessageBox::Show( dateTimePicker1->Value.ToString() );
}
public MyClass()
{
// Create a new DateTimePicker
DateTimePicker dateTimePicker1 = new DateTimePicker();
Controls.AddRange(new Control[] {dateTimePicker1});
MessageBox.Show(dateTimePicker1.Value.ToString());
dateTimePicker1.Value = DateTime.Now.AddDays(1);
MessageBox.Show(dateTimePicker1.Value.ToString());
}
Public Sub New()
' Create a new DateTimePicker
Dim dateTimePicker1 As New DateTimePicker()
Controls.AddRange(New Control() {dateTimePicker1})
MessageBox.Show(dateTimePicker1.Value.ToString())
dateTimePicker1.Value = DateTime.Now.AddDays(1)
MessageBox.Show(dateTimePicker1.Value.ToString())
End Sub
Keterangan
Value Jika properti belum diubah dalam kode atau oleh pengguna, properti diatur ke tanggal dan waktu saat ini (DateTime.Now).