SelectionRange クラス

定義

月間予定表コントロールで選択されている日付範囲を表します。

public ref class SelectionRange sealed
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.SelectionRangeConverter))]
public sealed class SelectionRange
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.SelectionRangeConverter))>]
type SelectionRange = class
Public NotInheritable Class SelectionRange
継承
SelectionRange
属性

次のMonthCalendar例では、 がSelectionRangeクリックされたときに 2 つのコントロールに入力された 2 つのTextBox日付に基づいて、コントロールの プロパティをButton設定します。 このコードでは、 コントロールの MonthCalendar 新しいインスタンス、2 つの TextBox コントロール、および Button が に Form作成されていることを前提としています。 有効な日付が含まれていることを Text 確認するために、テキスト ボックスに割り当てられている を検証するコードを追加することを検討してください。

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

注釈

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

コンストラクター

SelectionRange()

SelectionRange クラスの新しいインスタンスを初期化します。

SelectionRange(DateTime, DateTime)

指定した開始日および終了日を使用して、SelectionRange クラスの新しいインスタンスを初期化します。

SelectionRange(SelectionRange)

指定した選択範囲を使用して、SelectionRange クラスの新しいインスタンスを初期化します。

プロパティ

End

選択されている範囲の終了日時を取得または設定します。

Start

選択範囲の開始日時を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

SelectionRange を表す文字列を返します。

適用対象

こちらもご覧ください