次の方法で共有


SelectionRange.Start プロパティ

選択範囲の開始日時を取得または設定します。

Public Property Start As DateTime
[C#]
public DateTime Start {get; set;}
[C++]
public: __property DateTime get_Start();public: __property void set_Start(DateTime);
[JScript]
public function get Start() : DateTime;public function set Start(DateTime);

プロパティ値

選択範囲の開始を示す DateTime 値。

使用例

[Visual Basic, C#, C++] SelectionRange オブジェクトを作成し、その Start プロパティと End プロパティを設定し、 SelectionRange オブジェクトを MonthCalendar コントロールの SelectionRange プロパティに割り当てる例を次に示します。 DateChanged イベントが発生すると、 Start プロパティおよび End プロパティの値がテキスト ボックスに表示されます。この例は、2 つの TextBox コントロール、 Button コントロール、および MonthCalendar コントロールが配置された Form があることを前提にしています。

 
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

[C#] 
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();
}

[C++] 
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;
}

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();
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

SelectionRange クラス | SelectionRange メンバ | System.Windows.Forms 名前空間 | End