방법: .NET Compact Framework에서 DateTimePicker 클래스 사용

업데이트: 2007년 11월

.NET Compact Framework에서는 다음 멤버만 사용하는 DateTimePicker 클래스를 지원합니다.

OnValueChanged가 제공되므로 파생 클래스는 이벤트 처리기 대리자를 연결하지 않고도 이 메서드를 사용할 수 있습니다. 대리자 사용에 대한 자세한 내용은 이벤트 발생시키기를 참조하십시오.

참고:

Smartphone용 Windows Mobile 버전 5.0 소프트웨어에서 Smartphone용 DateTimePicker를 사용할 수 있습니다. Smartphone 컨트롤의 경우 탐색 키를 사용하여 값을 선택하므로 위로/아래로 선택기가 없습니다.

예제

다음 코드 예제에서는 .NET Compact Framework에서 DateTimePicker 컨트롤을 구성하는 방법을 보여 줍니다.

Private Sub SetupDateTimePicker()
   ' Set the MinDate and MaxDate.
   DateTimePicker1.MinDate = new DateTime(1985, 6, 12)
   DateTimePicker1.MaxDate = DateTime.Today

   'Set the format.
   DateTimePicker1.Format = DateTimePickerFormat.Short

   ' Define a custom format.
   DateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"

   ' If you want to use the custom format, change
   ' DateTimePickerFormat.Short to DateTimePickerFormat.Custom.

   ' Display the control with the up-down selector.
    DateTimePicker1.ShowUpDown = True

End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
    ' Respond to changes, such as using  
    ' the updated value in your application.
End Sub
private void SetupDateTimePicker()
{

   // Set the MinDate and MaxDate.
   dateTimePicker1.MinDate = new DateTime(1985, 6, 12);
   dateTimePicker1.MaxDate = DateTime.Today;

   // Set the format.
   dateTimePicker1.Format = DateTimePickerFormat.Short;

   // Define a custom format.
   dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";

   // If you want to use the custom format, change
   // DateTimePickerFormat.Short to DateTimePickerFormat.Custom.

   // Display the control with the up-down selector.
   dateTimePicker1.ShowUpDown = true;
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
 // Respond to changes, such as using
 // the updated value in your application.

}

코드 컴파일

이 예제에는 다음과 같은 네임스페이스에 대한 참조가 필요합니다.

참고 항목

기타 리소스

.NET Compact Framework의 Windows Forms 컨트롤

.NET Compact Framework의 그래픽 및 그리기