MonthCalendar.SelectionStart プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As MonthCalendar Dim value As DateTime value = instance.SelectionStart instance.SelectionStart = value
/** @property */ public DateTime get_SelectionStart () /** @property */ public void set_SelectionStart (DateTime value)
public function get SelectionStart () : DateTime public function set SelectionStart (value : DateTime)
選択範囲の最初の日を示す DateTime。


SelectionStart プロパティの値を SelectionEnd プロパティの現在の値よりも後の日付に設定した場合、SelectionEnd は自動的に SelectionStart と同じ値に設定されます。
MaxSelectionCount プロパティによって指定された日数を超える日付を SelectionStart に設定した場合、SelectionEnd の値は、次のように調整されます。SelectionEnd は、選択された日数が MaxSelectionCount に等しくなるように自動的に設定されます。
![]() |
---|
MaxSelectionCount は、SelectionStart と SelectionEnd との差ではなく、選択における日数を表します。たとえば、MaxSelectionCount が 7 (既定値) の場合は、SelectionStart と SelectionEnd の間隔が 6 日以下になります。 |

SelectionStart プロパティと SelectionEnd プロパティを使用する方法を次のコード例に示します。この例を実行するには、次のコードを MonthCalendar1 という名前の MonthCalendar コントロールが配置されているフォームに貼り付けて、フォームのコンストラクタまたは Load イベント処理メソッドから ShowAWeeksVacationOneMonthFromToday メソッドを呼び出します。
' Computes a week one month from today. Private Sub ShowAWeeksVacationOneMonthFromToday() Dim today As Date = monthCalendar1.TodayDate Dim vacationMonth As Integer = today.Month + 1 Dim vacationYear As Integer = today.Year If (today.Month = 12) Then vacationYear += 1 vacationMonth = 1 End If Me.monthCalendar1.SelectionStart = _ New Date(vacationYear, vacationMonth, today.Day - 1) Me.monthCalendar1.SelectionEnd = _ New Date(vacationYear, vacationMonth, today.Day + 6) End Sub
// Computes a week one month from today. private void ShowAWeeksVacationOneMonthFromToday() { System.DateTime today = this.MonthCalendar1.TodayDate; int vacationMonth = today.Month + 1; int vacationYear = today.Year; if (today.Month == 12) { vacationMonth = 1; ++vacationYear; } // 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); }
// Computes a week one month from today. void ShowAWeeksVacationOneMonthFromToday() { System::DateTime today = this->MonthCalendar1->TodayDate; int vacationMonth = today.Month + 1; int vacationYear = today.Year; if ( today.Month == 12 ) { vacationMonth = 1; ++vacationYear; } // Select the week using SelectionStart and SelectionEnd. this->MonthCalendar1->SelectionStart = System::DateTime( today.Year, vacationMonth, today.Day - 1 ); this->MonthCalendar1->SelectionEnd = System::DateTime( today.Year, vacationMonth, today.Day + 6 ); }
// Computes a week one month from today. private void ShowAWeeksVacationOneMonthFromToday() { System.DateTime today = this.monthCalendar1.get_TodayDate(); int vacationMonth = 1; if (today.get_Month() < 12) { vacationMonth = today.get_Month() + 1; } // Select the week using SelectionStart and SelectionEnd. this.monthCalendar1.set_SelectionStart( new System.DateTime(today.get_Year(), vacationMonth, today.get_Day() - 1)); this.monthCalendar1.set_SelectionEnd( new System.DateTime(today.get_Year(), vacationMonth, today.get_Day() + 6)); } //ShowAWeeksVacationOneMonthFromToday

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MonthCalendar.SelectionStart プロパティのページへのリンク