SelectionRange.End プロパティ

定義

選択されている範囲の終了日時を取得または設定します。Gets or sets the ending date and time of the selection range.

public:
 property DateTime End { DateTime get(); void set(DateTime value); };
public DateTime End { get; set; }
member this.End : DateTime with get, set
Public Property End As DateTime

プロパティ値

選択範囲の終了を示す DateTime 値。The ending DateTime value of the range.

次の例ではSelectionRange 、オブジェクトを作成StartEnd 、そのSelectionRangeプロパティとプロパティSelectionRangeを設定し、オブジェクトをMonthCalendarコントロールのプロパティに割り当てます。The following example creates a SelectionRange object, sets its Start and End properties, and assigns the SelectionRange object to the SelectionRange property of the MonthCalendar control. イベントが発生Startすると、プロパティとEndプロパティの値がテキストボックスに表示されます。 DateChangedWhen the DateChanged event is raised, the Start and End property values are displayed in the text boxes. この例Formでは、ととMonthCalendarいう 2 TextBoxつのコントロールButtonを持つがあることを前提としています。This example assumes that you have a Form with two TextBox controls, a Button, and a MonthCalendar control.

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

適用対象

こちらもご覧ください