SelectionRange Construtores
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Inicializa uma nova instância da SelectionRange classe.
Sobrecargas
| Name | Description |
|---|---|
| SelectionRange() |
Inicializa uma nova instância da SelectionRange classe. |
| 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 fim especificadas. |
SelectionRange()
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
- Origem:
- SelectionRange.cs
Inicializa uma nova instância da SelectionRange classe.
public:
SelectionRange();
public SelectionRange();
Public Sub New ()
Exemplos
O exemplo seguinte cria um SelectionRange objeto, define as suas Start propriedades and End e atribui o SelectionRange objeto à SelectionRange propriedade do MonthCalendar controlo. Quando o DateChanged evento é levantado, os Start valores das propriedades e End são apresentados nas caixas de texto. Este exemplo assume que tens um Form com dois TextBox controlos, um Button, e um MonthCalendar controlo.
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
Observações
Os Start valores e End são definidos para null quando este 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 seguinte cria um SelectionRange objeto, define as suas Start propriedades and End e atribui o SelectionRange objeto à SelectionRange propriedade do MonthCalendar controlo. Quando o DateChanged evento é levantado, os Start valores das propriedades e End são apresentados nas caixas de texto. Este exemplo assume que tens um Form com dois TextBox controlos, um Button, e um MonthCalendar controlo.
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
Observações
Os Start valores das propriedades e End são atribuídos aos Start valores das propriedades e End do objeto atribuído SelectionRange .
Ver 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 fim 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 no SelectionRange.
- upper
- DateTime
A data final no SelectionRange.
Exemplos
O exemplo seguinte define a SelectionRange propriedade de um MonthCalendar controlo com base em duas datas inseridas em dois TextBox controlos quando a Button é clicado. Este código assume que foram criadas novas instâncias de um MonthCalendar controlo, dois TextBox controlos e um Button num Form. Pode considerar adicionar código para validar as Text caixas de texto atribuídas e verificar se 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
Observações
Note
Se o lowerDateTime valor for superior aoupperDateTimevalor, o lower valor será atribuído à End propriedade em vez da propriedadeStart.