Export (0) Print
Expand All

SelectionRange.Start Property

Gets or sets the starting date and time of the selection range.

[Visual Basic]
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);

Property Value

The starting DateTime value of the range.

Example

[Visual Basic, C#, C++] 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. When the DateChanged event is raised, the Start and End property values are displayed in the text boxes. This example assumes that you have a Form with two TextBox controls, a Button, and a MonthCalendar control.

[Visual Basic] 
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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

SelectionRange Class | SelectionRange Members | System.Windows.Forms Namespace | End

Show:
© 2014 Microsoft