다음을 통해 공유


SelectionRange 생성자

정의

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

오버로드

Name Description
SelectionRange()

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

SelectionRange(SelectionRange)

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

SelectionRange(DateTime, DateTime)

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

SelectionRange()

Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs

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

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

예제

다음 예제에서는 개체를 SelectionRange 만들고, 개체 StartEnd 속성을 설정하고, 컨트롤의 MonthCalendar 속성에 개체를 SelectionRange 할당합니다SelectionRange. DateChanged 이벤트가 발생하면 Start 텍스트 상자에 속성 값과 End 속성 값이 표시됩니다. 이 예제에서는 컨트롤과 Form 컨트롤이 두 TextBox 개 있다고 가정합니다ButtonMonthCalendar.

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

설명

End 값은 Start 이 생성자를 사용할 때로 설정 null 됩니다.

적용 대상

SelectionRange(SelectionRange)

Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs

지정된 선택 범위를 사용하여 클래스의 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)

매개 변수

예제

다음 예제에서는 개체를 SelectionRange 만들고, 개체 StartEnd 속성을 설정하고, 컨트롤의 MonthCalendar 속성에 개체를 SelectionRange 할당합니다SelectionRange. DateChanged 이벤트가 발생하면 Start 텍스트 상자에 속성 값과 End 속성 값이 표시됩니다. 이 예제에서는 컨트롤과 Form 컨트롤이 두 TextBox 개 있다고 가정합니다ButtonMonthCalendar.

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 속성 값에는 할당된 개체의 Start 속성 값과 End 속성 값이 할당 SelectionRange 됩니다.

추가 정보

적용 대상

SelectionRange(DateTime, DateTime)

Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs
Source:
SelectionRange.cs

지정된 시작 및 종료 날짜를 사용하여 클래스의 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 클릭할 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

설명

메모

값이 lowerDateTimelower 보다 upperDateTime 크면 속성 대신 속성에 End 값이 Start 할당됩니다.

추가 정보

적용 대상