SelectionRange クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


SelectionRange は、MonthCalendar コントロール上で選択および強調表示されている日付または日付範囲を表します。選択されている日数が 1 日だけの場合は、Start プロパティと End プロパティの値が等しくなります。SelectionRange は、ユーザーがある日付をクリックしたまま目的の日付範囲をマウス ポインタでドラッグして選択して変更できます。また、日付範囲をコードで設定することもできます。たとえば、2 つの TextBox コントロールまたは 2 つの DateTimePicker コントロールを使用してユーザーが日付範囲を指定するようにし、入力されたデータを基に SelectionRange を設定できます。

Button がクリックされたときに、2 つの TextBox コントロールに入力された 2 つの日付に基づいて、MonthCalendar コントロールの SelectionRange プロパティを設定する例を次に示します。このコードは、MonthCalendar コントロールの新しいインスタンス、2 つの TextBox コントロール、および Button が Form 上に作成されていることを前提にしています。テキスト ボックスに入力された Text を検証するためのコードを追加し、入力された日付が有効かどうかを確認できます。
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
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: 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.set_SelectionRange( new SelectionRange(DateTime.Parse(textBox1.get_Text()), DateTime.Parse(textBox2.get_Text()))); } catch (System.Exception ex) { MessageBox.Show(ex.get_Message()); } } //button1_Click

System.Windows.Forms.SelectionRange


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SelectionRange コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SelectionRange コンストラクタ (SelectionRange)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SelectionRange コンストラクタ

名前 | 説明 |
---|---|
SelectionRange () | SelectionRange クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
SelectionRange (SelectionRange) | 指定した選択範囲を使用して、SelectionRange クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
SelectionRange (DateTime, DateTime) | 指定した開始日および終了日を使用して、SelectionRange クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |

SelectionRange コンストラクタ (DateTime, DateTime)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



Button がクリックされたときに、2 つの TextBox コントロールに入力された 2 つの日付に基づいて、MonthCalendar コントロールの SelectionRange プロパティを設定する例を次に示します。このコードは、MonthCalendar コントロールの新しいインスタンス、2 つの TextBox コントロール、および Button が Form 上に作成されていることを前提にしています。テキスト ボックスに入力された Text を検証するためのコードを追加し、入力された日付が有効かどうかを確認できます。
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
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: 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.set_SelectionRange( new SelectionRange(DateTime.Parse(textBox1.get_Text()), DateTime.Parse(textBox2.get_Text()))); } catch (System.Exception ex) { MessageBox.Show(ex.get_Message()); } } //button1_Click

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SelectionRange プロパティ
SelectionRange メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | オーバーライドされます。 SelectionRange を表す文字列を返します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

SelectionRange メンバ
SelectionRange データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | オーバーライドされます。 SelectionRange を表す文字列を返します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からSelectionRangeを検索する場合は、下記のリンクをクリックしてください。

- SelectionRangeのページへのリンク