SelectionRange 생성자

정의

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

오버로드

SelectionRange()

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

SelectionRange(SelectionRange)

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

SelectionRange(DateTime, DateTime)

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

SelectionRange()

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

public:
 SelectionRange();
public SelectionRange ();
Public Sub New ()

예제

다음 예제에서는 SelectionRange 개체, 설정 해당 StartEnd 속성 및 할당을 SelectionRange 개체를 SelectionRange 속성은 MonthCalendar 컨트롤. 경우는 DateChanged 이벤트가 발생 합니다 StartEnd 속성 값은 텍스트 상자에 표시 됩니다. 이 예에서는 있다고 가정를 Form 두 개의 TextBox 컨트롤을 Button, 및 MonthCalendar 제어 합니다.

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Create a SelectionRange object and set its Start and End properties.
      SelectionRange^ sr = gcnew SelectionRange;
      sr->Start = DateTime::Parse( this->textBox1->Text );
      sr->End = DateTime::Parse( this->textBox2->Text );
      
      /* Assign the SelectionRange object to the
            SelectionRange property of the MonthCalendar control. */
      this->monthCalendar1->SelectionRange = sr;
   }

   void monthCalendar1_DateChanged( Object^ /*sender*/, DateRangeEventArgs^ /*e*/ )
   {
      /* Display the Start and End property values of
            the SelectionRange object in the text boxes. */
      this->textBox1->Text = monthCalendar1->SelectionRange->Start.Date.ToShortDateString();
      this->textBox2->Text = monthCalendar1->SelectionRange->End.Date.ToShortDateString();
   }
private void button1_Click(object sender, System.EventArgs e)
{
   // Create a SelectionRange object and set its Start and End properties.
   SelectionRange sr = new SelectionRange();
   sr.Start = DateTime.Parse(this.textBox1.Text);
   sr.End = DateTime.Parse(this.textBox2.Text);
   /* Assign the SelectionRange object to the 
      SelectionRange property of the MonthCalendar control. */
   this.monthCalendar1.SelectionRange = sr;
}

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
   /* Display the Start and End property values of 
      the SelectionRange object in the text boxes. */
   this.textBox1.Text = 
     monthCalendar1.SelectionRange.Start.Date.ToShortDateString();
   this.textBox2.Text = 
     monthCalendar1.SelectionRange.End.Date.ToShortDateString();
}
Private Sub button1_Click(sender As Object, _
  e As EventArgs) Handles button1.Click
   ' Create a SelectionRange object and set its Start and End properties.
   Dim sr As New SelectionRange()
   sr.Start = DateTime.Parse(Me.textBox1.Text)
   sr.End = DateTime.Parse(Me.textBox2.Text)
   ' Assign the SelectionRange object to the
   ' SelectionRange property of the MonthCalendar control. 
   Me.monthCalendar1.SelectionRange = sr
End Sub 


Private Sub monthCalendar1_DateChanged(sender As Object, _
  e As DateRangeEventArgs) Handles monthCalendar1.DateChanged
   ' Display the Start and End property values of
   ' the SelectionRange object in the text boxes. 
   Me.textBox1.Text = monthCalendar1.SelectionRange.Start.Date.ToShortDateString()
   Me.textBox2.Text = monthCalendar1.SelectionRange.End.Date.ToShortDateString()
End Sub

설명

합니다 Start 하 고 End 값으로 설정 됩니다 null 이 생성자를 사용 하는 경우.

적용 대상

SelectionRange(SelectionRange)

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

public:
 SelectionRange(System::Windows::Forms::SelectionRange ^ range);
public SelectionRange (System.Windows.Forms.SelectionRange range);
new System.Windows.Forms.SelectionRange : System.Windows.Forms.SelectionRange -> System.Windows.Forms.SelectionRange
Public Sub New (range As SelectionRange)

매개 변수

range
SelectionRange

기존 SelectionRange입니다.

예제

다음 예제에서는 SelectionRange 개체, 설정 해당 StartEnd 속성 및 할당을 SelectionRange 개체를 SelectionRange 속성은 MonthCalendar 컨트롤. 경우는 DateChanged 이벤트가 발생 합니다 StartEnd 속성 값은 텍스트 상자에 표시 됩니다. 이 예에서는 있다고 가정를 Form 두 개의 TextBox 컨트롤을 Button, 및 MonthCalendar 제어 합니다.

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Create a SelectionRange object and set its Start and End properties.
      SelectionRange^ sr = gcnew SelectionRange;
      sr->Start = DateTime::Parse( this->textBox1->Text );
      sr->End = DateTime::Parse( this->textBox2->Text );
      
      /* Assign the SelectionRange object to the
            SelectionRange property of the MonthCalendar control. */
      this->monthCalendar1->SelectionRange = sr;
   }

   void monthCalendar1_DateChanged( Object^ /*sender*/, DateRangeEventArgs^ /*e*/ )
   {
      /* Display the Start and End property values of
            the SelectionRange object in the text boxes. */
      this->textBox1->Text = monthCalendar1->SelectionRange->Start.Date.ToShortDateString();
      this->textBox2->Text = monthCalendar1->SelectionRange->End.Date.ToShortDateString();
   }
private void button1_Click(object sender, System.EventArgs e)
{
   // Create a SelectionRange object and set its Start and End properties.
   SelectionRange sr = new SelectionRange();
   sr.Start = DateTime.Parse(this.textBox1.Text);
   sr.End = DateTime.Parse(this.textBox2.Text);
   /* Assign the SelectionRange object to the 
      SelectionRange property of the MonthCalendar control. */
   this.monthCalendar1.SelectionRange = sr;
}

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
   /* Display the Start and End property values of 
      the SelectionRange object in the text boxes. */
   this.textBox1.Text = 
     monthCalendar1.SelectionRange.Start.Date.ToShortDateString();
   this.textBox2.Text = 
     monthCalendar1.SelectionRange.End.Date.ToShortDateString();
}
Private Sub button1_Click(sender As Object, _
  e As EventArgs) Handles button1.Click
   ' Create a SelectionRange object and set its Start and End properties.
   Dim sr As New SelectionRange()
   sr.Start = DateTime.Parse(Me.textBox1.Text)
   sr.End = DateTime.Parse(Me.textBox2.Text)
   ' Assign the SelectionRange object to the
   ' SelectionRange property of the MonthCalendar control. 
   Me.monthCalendar1.SelectionRange = sr
End Sub 


Private Sub monthCalendar1_DateChanged(sender As Object, _
  e As DateRangeEventArgs) Handles monthCalendar1.DateChanged
   ' Display the Start and End property values of
   ' the SelectionRange object in the text boxes. 
   Me.textBox1.Text = monthCalendar1.SelectionRange.Start.Date.ToShortDateString()
   Me.textBox2.Text = monthCalendar1.SelectionRange.End.Date.ToShortDateString()
End Sub

설명

StartEnd 속성 값이 할당 되는 StartEnd 속성 값이 할당된 된 SelectionRange 개체입니다.

추가 정보

적용 대상

SelectionRange(DateTime, DateTime)

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

public:
 SelectionRange(DateTime lower, DateTime upper);
public SelectionRange (DateTime lower, DateTime upper);
new System.Windows.Forms.SelectionRange : DateTime * DateTime -> System.Windows.Forms.SelectionRange
Public Sub New (lower As DateTime, upper As DateTime)

매개 변수

lower
DateTime

SelectionRange의 시작 날짜입니다.

upper
DateTime

SelectionRange의 끝 날짜입니다.

예제

다음 예제에서는 SelectionRange 의 속성을 MonthCalendar 컨트롤에 입력 된 두 개의 날짜에 따라 TextBox 시기를 제어를 Button 를 클릭 합니다. 이 코드의 새 인스턴스를 가정를 MonthCalendar 컨트롤을 두 TextBox 컨트롤 및 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

설명

참고

경우는 lowerDateTime 값 보다 크면를 upperDateTime 값을 lower 에 할당할 값을 End 속성 대신를 Start 속성.

추가 정보

적용 대상