SelectionRange Construtores
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Inicializa uma nova instância da classe SelectionRange.
Sobrecargas
| Nome | Description |
|---|---|
| SelectionRange() |
Inicializa uma nova instância da classe SelectionRange. |
| SelectionRange(SelectionRange) |
Inicializa uma nova instância da SelectionRange classe com o intervalo de seleção especificado. |
| SelectionRange(DateTime, DateTime) |
Inicializa uma nova instância da SelectionRange classe com as datas de início e término especificadas. |
SelectionRange()
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
Inicializa uma nova instância da classe SelectionRange.
public:
SelectionRange();
public SelectionRange();
Public Sub New ()
Exemplos
O exemplo a seguir cria um SelectionRange objeto, define suas Start propriedades e End atribui o SelectionRange objeto à SelectionRange propriedade do MonthCalendar controle. Quando o DateChanged evento é acionado, os Start valores e End a propriedade são exibidos nas caixas de texto. Este exemplo pressupõe que você tenha um Form controle com dois TextBox controles, um Buttone um MonthCalendar controle.
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
Comentários
Os Start valores e os End valores são definidos para null quando esse construtor é usado.
Aplica-se a
SelectionRange(SelectionRange)
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
Inicializa uma nova instância da SelectionRange classe com o intervalo de seleção especificado.
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)
Parâmetros
- range
- SelectionRange
O existente SelectionRange.
Exemplos
O exemplo a seguir cria um SelectionRange objeto, define suas Start propriedades e End atribui o SelectionRange objeto à SelectionRange propriedade do MonthCalendar controle. Quando o DateChanged evento é acionado, os Start valores e End a propriedade são exibidos nas caixas de texto. Este exemplo pressupõe que você tenha um Form controle com dois TextBox controles, um Buttone um MonthCalendar controle.
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
Comentários
Os Start valores e End a propriedade são atribuídos aos Start valores e End à propriedade do objeto atribuído SelectionRange .
Confira também
Aplica-se a
SelectionRange(DateTime, DateTime)
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
Inicializa uma nova instância da SelectionRange classe com as datas de início e término especificadas.
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)
Parâmetros
- lower
- DateTime
A data de início na SelectionRange.
- upper
- DateTime
A data de término na SelectionRange.
Exemplos
O exemplo a seguir define a SelectionRange propriedade de um MonthCalendar controle com base em duas datas inseridas em dois TextBox controles quando um Button é clicado. Esse código pressupõe que novas instâncias de um MonthCalendar controle, dois TextBox controles e um Button tenham sido criados em um Form. Você pode considerar a adição de código para validar as Text caixas de texto atribuídas para verificar se elas contêm datas válidas.
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
Comentários
Nota
Se o lowerDateTime valor for maior que oDateTimeuppervalor, o lower valor será atribuído à End propriedade em vez da Start propriedade.