選択されている日付範囲の開始日を取得または設定します。
Public Property SelectionStart As DateTime
[C#]
public DateTime SelectionStart {get; set;}
[C++]
public: __property DateTime get_SelectionStart();public: __property void set_SelectionStart(DateTime);
[JScript]
public function get SelectionStart() : DateTime;public function set SelectionStart(DateTime);
プロパティ値
選択範囲の最初の日を示す DateTime 。
例外
例外の種類 | 条件 |
---|---|
ArgumentException | 日付の値が MinDate 未満です。
または 日付の値が MaxDate を超えています。 |
解説
SelectionStart を現在の SelectionEnd より後の日付に設定した場合、 SelectionEnd は自動的に SelectionStart に等しい値に設定されます。
MaxSelectionCount プロパティによって指定された日数を超える日付を SelectionStart に設定した場合、 SelectionEnd の値は、次のように調整されます。 SelectionEnd は、選択された日数が MaxSelectionCount に等しくなるように自動的に設定されます。
メモ MaxSelectionCount は、 SelectionStart と SelectionEnd との差ではなく、選択における日数を表します。たとえば、 MaxSelectionCount が 7 (既定値) の場合は、 SelectionStart と SelectionEnd の間隔が 6 日以下になります。
使用例
[Visual Basic, C#] SelectionStart プロパティと SelectionEnd プロパティを使用する方法を次のコード例に示します。この例を実行するには、MonthCalendar1 という名前の MonthCalendar コントロールが配置されているフォームに、次のコードを貼り付けて、フォームのコンストラクタまたは Load メソッドから ShowAWeeksVacationOneMonthFromToday メソッドを呼び出します。
' Computes a week one month from today.
Private Sub ShowAWeeksVacationOneMonthFromToday()
Dim today As Date = Me.MonthCalendar1.TodayDate
Dim vacationMonth As Integer = 1
If (today.Month < 12) Then
vacationMonth = today.Month + 1
End If
' Select the week using SelectionStart and SelectionEnd.
Me.MonthCalendar1.SelectionStart = _
New Date(today.Year, vacationMonth, today.Day - 1)
Me.MonthCalendar1.SelectionEnd = _
New Date(today.Year, vacationMonth, today.Day + 6)
End Sub
[C#]
// Computes a week one month from today.
private void ShowAWeeksVacationOneMonthFromToday()
{
System.DateTime today = this.MonthCalendar1.TodayDate;
int vacationMonth = 1;
if (today.Month < 12)
{
vacationMonth = today.Month + 1;
}
// Select the week using SelectionStart and SelectionEnd.
this.MonthCalendar1.SelectionStart =
new System.DateTime(today.Year, vacationMonth, today.Day-1);
this.MonthCalendar1.SelectionEnd =
new System.DateTime(today.Year, vacationMonth, today.Day+6);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
MonthCalendar クラス | MonthCalendar メンバ | System.Windows.Forms 名前空間 | SelectionRange | SelectionEnd | SetSelectionRange