SelectionRange Costruttori
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inizializza una nuova istanza della classe SelectionRange.
Overload
SelectionRange() |
Inizializza una nuova istanza della classe SelectionRange. |
SelectionRange(SelectionRange) |
Inizializza una nuova istanza della classe SelectionRange con l'intervallo di selezione specificato. |
SelectionRange(DateTime, DateTime) |
Inizializza una nuova istanza della classe SelectionRange con la data iniziale e finale specificate. |
SelectionRange()
Inizializza una nuova istanza della classe SelectionRange.
public:
SelectionRange();
public SelectionRange ();
Public Sub New ()
Esempio
L'esempio seguente crea un SelectionRange oggetto, imposta le Start relative proprietà e End e assegna l'oggetto SelectionRange alla SelectionRange proprietà del MonthCalendar controllo. Quando viene generato l'evento, i DateChangedStart valori delle 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
Commenti
I Start valori e End vengono impostati su null
quando viene usato questo costruttore.
Si applica a
SelectionRange(SelectionRange)
Inizializza una nuova istanza della classe SelectionRange con l'intervallo di selezione specificato.
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)
Parametri
- range
- SelectionRange
Oggetto SelectionRange esistente.
Esempio
L'esempio seguente crea un SelectionRange oggetto, imposta le Start relative proprietà e End e assegna l'oggetto SelectionRange alla SelectionRange proprietà del MonthCalendar controllo. Quando viene generato l'evento, i DateChangedStart valori delle 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
Commenti
I Start valori delle proprietà e End vengono assegnati i Start valori e End delle proprietà dell'oggetto assegnato SelectionRange .
Vedi anche
Si applica a
SelectionRange(DateTime, DateTime)
Inizializza una nuova istanza della classe SelectionRange con la data iniziale e finale specificate.
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)
Parametri
- lower
- DateTime
La data iniziale nell'oggetto SelectionRange.
- upper
- DateTime
La data finale nell'oggetto SelectionRange.
Esempio
Nell'esempio seguente viene impostata la SelectionRange proprietà di un MonthCalendar controllo in base a due date immesse in due TextBox controlli quando viene fatto clic su un oggetto Button . Questo codice presuppone nuove istanze di un MonthCalendar controllo, due TextBox controlli e un Button oggetto è stato creato in un Formoggetto . È possibile aggiungere codice per convalidare l'assegnazione Text alle caselle di testo per verificare che contengano date valide.
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
Commenti
Nota
Se il lower
DateTime valore è maggiore upper
DateTime del valore, il lower
valore verrà assegnato alla proprietà anziché alla EndStart proprietà.
Vedi anche
Si applica a
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per