SelectionRange.End Proprietà

Definizione

Ottiene o imposta la data e l'ora finali dell'intervallo di selezione.

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

Valore della proprietà

Il valore dell'oggetto DateTime finale dell'intervallo.

Esempio

Nell'esempio seguente viene creato un SelectionRange oggetto , vengono impostate le Start relative proprietà e End e viene assegnato l'oggetto SelectionRange alla SelectionRange proprietà del MonthCalendar controllo . Quando viene generato l'evento DateChanged , i valori delle Start proprietà e End vengono visualizzati nelle caselle di testo. In questo esempio si presuppone che sia presente un Form oggetto con due TextBox controlli, un Buttonoggetto e un MonthCalendar controllo .

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

Si applica a

Vedi anche