다음을 통해 공유


SelectionRange 클래스

MonthCalendar 컨트롤의 날짜 선택 범위를 나타냅니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public NotInheritable Class SelectionRange
‘사용 방법
Dim instance As SelectionRange
public sealed class SelectionRange
public ref class SelectionRange sealed
public final class SelectionRange
public final class SelectionRange

설명

SelectionRangeMonthCalendar 컨트롤에서 선택되고 강조 표시된 날짜입니다. 하나의 날짜만 선택되면 StartEnd 속성 값은 같습니다. 원하는 날짜 전체를 마우스 포인터를 끄는 동안 날짜 하나를 클릭하여 SelectionRange를 변경하거나 코드에서 날짜 범위를 설정할 수 있습니다. 예를 들어, 두 개의 TextBox 컨트롤 또는 두 개의 DateTimePicker 컨트롤에 날짜 범위를 입력하고 해당 날짜에 따라 SelectionRange를 설정할 수 있습니다.

예제

다음 예제에서는 Button을 클릭할 때 TextBox 컨트롤에 입력된 두 개의 날짜에 따라 MonthCalendar 컨트롤의 SelectionRange 속성을 설정합니다. 이 코드는 Form에서 하나의 MonthCalendar 컨트롤, 두 개의 TextBox 컨트롤 및 Button의 새로운 인스턴스가 만들어진 것으로 가정합니다. 텍스트 상자에 할당된 Text의 유효성을 검사하여 올바른 날짜를 포함하는지 확인하는 코드를 추가할 수 있습니다.

Private Sub button1_Click(sender As Object, e As EventArgs)
   ' Set the SelectionRange with start and end dates from text boxes.
   Try
      monthCalendar1.SelectionRange = New SelectionRange( _
        DateTime.Parse(textBox1.Text), _
        DateTime.Parse(textBox2.Text))
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
End Sub
private void button1_Click(object sender,
                           EventArgs e)
{
   // Set the SelectionRange with start and end dates from text boxes.
   try
   {
      monthCalendar1.SelectionRange = new SelectionRange(
        DateTime.Parse(textBox1.Text),
        DateTime.Parse(textBox2.Text));
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}
private:
   void button1_Click( Object^ sender, EventArgs^ e )
   {
      // Set the SelectionRange with start and end dates from text boxes.
      try
      {
         monthCalendar1->SelectionRange = gcnew SelectionRange(
            DateTime::Parse( textBox1->Text ),
            DateTime::Parse( textBox2->Text ) );
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( ex->Message );
      }
   }
private void button1_Click(Object sender, EventArgs e)
{
    // Set the SelectionRange with start and end dates from text boxes.
    try {
        monthCalendar1.set_SelectionRange(
        new SelectionRange(DateTime.Parse(textBox1.get_Text()), 
            DateTime.Parse(textBox2.get_Text())));
    }
    catch (System.Exception ex) {
        MessageBox.Show(ex.get_Message());
    }
} //button1_Click

상속 계층 구조

System.Object
  System.Windows.Forms.SelectionRange

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

SelectionRange 멤버
System.Windows.Forms 네임스페이스
DateTimePicker 클래스
DateTime