SelectionRange Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de SelectionRange klasse.
Overloads
| Name | Description |
|---|---|
| SelectionRange() |
Initialiseert een nieuw exemplaar van de SelectionRange klasse. |
| SelectionRange(SelectionRange) |
Initialiseert een nieuw exemplaar van de SelectionRange klasse met het opgegeven selectiebereik. |
| SelectionRange(DateTime, DateTime) |
Initialiseert een nieuw exemplaar van de SelectionRange klasse met de opgegeven begin- en einddatums. |
SelectionRange()
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
Initialiseert een nieuw exemplaar van de SelectionRange klasse.
public:
SelectionRange();
public SelectionRange();
Public Sub New ()
Voorbeelden
In het volgende voorbeeld wordt een SelectionRange object gemaakt, de bijbehorende en Start eigenschappen ingesteld End en wordt het SelectionRange object toegewezen aan de SelectionRange eigenschap van het MonthCalendar besturingselement. Wanneer de DateChanged gebeurtenis wordt gegenereerd, worden de Start eigenschapswaarden End weergegeven in de tekstvakken. In dit voorbeeld wordt ervan uitgegaan dat u een Form met twee TextBox besturingselementen, een Buttonen een MonthCalendar besturingselement hebt.
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
Opmerkingen
De Start waarden worden End ingesteld op null wanneer deze constructor wordt gebruikt.
Van toepassing op
SelectionRange(SelectionRange)
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
Initialiseert een nieuw exemplaar van de SelectionRange klasse met het opgegeven selectiebereik.
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)
Parameters
- range
- SelectionRange
De bestaande SelectionRange.
Voorbeelden
In het volgende voorbeeld wordt een SelectionRange object gemaakt, de bijbehorende en Start eigenschappen ingesteld End en wordt het SelectionRange object toegewezen aan de SelectionRange eigenschap van het MonthCalendar besturingselement. Wanneer de DateChanged gebeurtenis wordt gegenereerd, worden de Start eigenschapswaarden End weergegeven in de tekstvakken. In dit voorbeeld wordt ervan uitgegaan dat u een Form met twee TextBox besturingselementen, een Buttonen een MonthCalendar besturingselement hebt.
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
Opmerkingen
De Start waarden en End eigenschapswaarden worden toegewezen aan de Start en End eigenschapswaarden van het toegewezen SelectionRange object.
Zie ook
Van toepassing op
SelectionRange(DateTime, DateTime)
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
- Bron:
- SelectionRange.cs
Initialiseert een nieuw exemplaar van de SelectionRange klasse met de opgegeven begin- en einddatums.
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)
Parameters
- lower
- DateTime
De begindatum in de SelectionRange.
- upper
- DateTime
De einddatum in de SelectionRange.
Voorbeelden
In het volgende voorbeeld wordt de SelectionRange eigenschap van een MonthCalendar besturingselement ingesteld op basis van twee datums die in twee TextBox besturingselementen zijn ingevoerd wanneer op een Button besturingselement wordt geklikt. In deze code wordt ervan uitgegaan dat er nieuwe exemplaren van een MonthCalendar besturingselement, twee TextBox besturingselementen en een Button zijn gemaakt op een Form. U kunt overwegen code toe te voegen om de Text toegewezen tekstvakken te valideren om te controleren of deze geldige datums bevatten.
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
Opmerkingen
Note
Als de lowerDateTime waarde groter is dan de upperDateTime waarde, wordt de lower waarde toegewezen aan de End eigenschap in plaats van de Start eigenschap.