SelectionRange Konstruktory
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Inicjuje nowe wystąpienie klasy SelectionRange.
Przeciążenia
| Nazwa | Opis |
|---|---|
| SelectionRange() |
Inicjuje nowe wystąpienie klasy SelectionRange. |
| SelectionRange(SelectionRange) |
Inicjuje nowe wystąpienie SelectionRange klasy z określonym zakresem wyboru. |
| SelectionRange(DateTime, DateTime) |
Inicjuje nowe wystąpienie SelectionRange klasy z określonymi datami początkowymi i końcowymi. |
SelectionRange()
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
Inicjuje nowe wystąpienie klasy SelectionRange.
public:
SelectionRange();
public SelectionRange();
Public Sub New ()
Przykłady
Poniższy przykład tworzy SelectionRange obiekt, ustawia jego Start właściwości i End i przypisuje SelectionRange obiekt do SelectionRange właściwości kontrolki MonthCalendar . Po wystąpieniu DateChangedStart zdarzenia wartości właściwości i End są wyświetlane w polach tekstowych. W tym przykładzie przyjęto założenie, że masz Form dwie TextBox kontrolki , Buttoni kontrolkę MonthCalendar .
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
Uwagi
Wartości Start i End są ustawiane na null wartość , gdy ten konstruktor jest używany.
Dotyczy
SelectionRange(SelectionRange)
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
Inicjuje nowe wystąpienie SelectionRange klasy z określonym zakresem wyboru.
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)
Parametry
- range
- SelectionRange
Istniejący SelectionRangeelement .
Przykłady
Poniższy przykład tworzy SelectionRange obiekt, ustawia jego Start właściwości i End i przypisuje SelectionRange obiekt do SelectionRange właściwości kontrolki MonthCalendar . Po wystąpieniu DateChangedStart zdarzenia wartości właściwości i End są wyświetlane w polach tekstowych. W tym przykładzie przyjęto założenie, że masz Form dwie TextBox kontrolki , Buttoni kontrolkę MonthCalendar .
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
Uwagi
Wartości Start właściwości i End są przypisywane Start wartości właściwości i End przypisanego SelectionRange obiektu.
Zobacz też
Dotyczy
SelectionRange(DateTime, DateTime)
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
- Źródło:
- SelectionRange.cs
Inicjuje nowe wystąpienie SelectionRange klasy z określonymi datami początkowymi i końcowymi.
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)
Parametry
- lower
- DateTime
Data początkowa w pliku SelectionRange.
- upper
- DateTime
Data zakończenia w pliku SelectionRange.
Przykłady
W poniższym przykładzie właściwość kontrolki jest ustawiana SelectionRange na podstawie dwóch dat wprowadzonych do dwóch TextBox kontrolek po kliknięciu elementu Button .MonthCalendar W tym kodzie przyjęto założenie, że nowe wystąpienia kontrolki MonthCalendar , dwie TextBox kontrolki i element Button zostały utworzone na obiekcie Form. Możesz rozważyć dodanie kodu w celu zweryfikowania przypisanego Text do pól tekstowych w celu sprawdzenia, czy zawierają prawidłowe daty.
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
Uwagi
Nuta
lower
DateTime Jeśli wartość jest większa niż upperDateTime wartość, lower wartość zostanie przypisana do End właściwości zamiast Start właściwości .