指定した選択範囲を使用して、SelectionRange クラスの新しいインスタンスを初期化します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
'宣言
Public Sub New ( _
range As SelectionRange _
)
'使用
Dim range As SelectionRange
Dim instance As New SelectionRange(range)
public SelectionRange (
SelectionRange range
)
public:
SelectionRange (
SelectionRange^ range
)
public SelectionRange (
SelectionRange range
)
public function SelectionRange (
range : SelectionRange
)
パラメータ
- range
既存の SelectionRange。
解説
Start プロパティおよび End プロパティに、値が指定されている SelectionRange オブジェクトの Start プロパティ値および End プロパティ値が代入されます。
使用例
SelectionRange オブジェクトを作成し、その Start プロパティと End プロパティを設定し、SelectionRange オブジェクトを MonthCalendar コントロールの SelectionRange プロパティに割り当てる例を次に示します。DateChanged イベントが発生すると、Start プロパティおよび End プロパティの値がテキスト ボックスに表示されます。この例は、2 つの TextBox コントロール、Button コントロール、および MonthCalendar コントロールが配置された Form があることを前提にしています。
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
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:
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.set_Start(DateTime.Parse(this.textBox1.get_Text()));
sr.set_End(DateTime.Parse(this.textBox2.get_Text()));
/* Assign the SelectionRange object to the
SelectionRange property of the MonthCalendar control. */
this.monthCalendar1.set_SelectionRange(sr);
} //button1_Click
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.set_Text(monthCalendar1.get_SelectionRange().get_Start().
get_Date().ToShortDateString());
this.textBox2.set_Text(monthCalendar1.get_SelectionRange().get_End().
get_Date().ToShortDateString());
} //monthCalendar1_DateChanged
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0
参照
関連項目
SelectionRange クラス
SelectionRange メンバ
System.Windows.Forms 名前空間
Start
End