다음을 통해 공유


SelectionRange 클래스

정의

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

public ref class SelectionRange sealed
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.SelectionRangeConverter))]
public sealed class SelectionRange
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.SelectionRangeConverter))>]
type SelectionRange = class
Public NotInheritable Class SelectionRange
상속
SelectionRange
특성

예제

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

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.SelectionRange = new SelectionRange(
        DateTime.Parse(textBox1.Text),
        DateTime.Parse(textBox2.Text));
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}
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

설명

SelectionRange 컨트롤에서 선택되고 강조 표시된 날짜 또는 날짜입니다MonthCalendar. 날짜가 하나만 선택되면 Start 속성 값과 End 속성 값이 같습니다. SelectionRange 원하는 날짜에 마우스 포인터를 끌 때 날짜를 클릭하면 변경하거나 코드에서 범위를 설정할 수 있습니다. 예를 들어 사용자가 두 개의 컨트롤 또는 두 DateTimePicker 개의 TextBox 컨트롤에 날짜 범위를 입력하고 해당 날짜를 기준으로 설정 SelectionRange 하도록 할 수 있습니다.

생성자

Name Description
SelectionRange()

SelectionRange 클래스의 새 인스턴스를 초기화합니다.

SelectionRange(DateTime, DateTime)

지정된 시작 및 종료 날짜를 사용하여 클래스의 SelectionRange 새 인스턴스를 초기화합니다.

SelectionRange(SelectionRange)

지정된 선택 범위를 사용하여 클래스의 SelectionRange 새 인스턴스를 초기화합니다.

속성

Name Description
End

선택 범위의 종료 날짜 및 시간을 가져오거나 설정합니다.

Start

선택 범위의 시작 날짜와 시간을 가져오거나 설정합니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

를 나타내는 문자열을 SelectionRange반환합니다.

적용 대상

추가 정보