Share via


Calendar.SelectedDates プロパティ

定義

ASP.NET の SelectedDatesCollection クラスから、選択されている日付のコレクションを取得します。 この API は、互換性のために残されています。 ASP.NET モバイル アプリケーションを開発する方法については、「ASP.NET を使用した Mobile Apps & サイト」を参照してください。

public:
 property System::Web::UI::WebControls::SelectedDatesCollection ^ SelectedDates { System::Web::UI::WebControls::SelectedDatesCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.SelectedDatesCollection SelectedDates { get; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectedDates : System.Web.UI.WebControls.SelectedDatesCollection
Public ReadOnly Property SelectedDates As SelectedDatesCollection

プロパティ値

選択されている日付のコレクション。

属性

次のコード例では、 プロパティを使用して、現在の SelectedDates 月のすべての水曜日を選択する方法を示します。 この例は、概要に関する大きなコード サンプルの Calendar 一部です。

protected void Command1_Click(object sender, EventArgs e)
{
    int currentDay = Calendar1.VisibleDate.Day;
    int currentMonth = Calendar1.VisibleDate.Month;
    int currentYear = Calendar1.VisibleDate.Year;
    Calendar1.SelectedDates.Clear();

    // Add all Wednesdays to the collection.
    for (int i = 1; i <= System.DateTime.DaysInMonth(currentYear,
           currentMonth); i++)
    {
        DateTime targetDate = new DateTime(currentYear, currentMonth, i);
        if (targetDate.DayOfWeek == DayOfWeek.Wednesday)
            Calendar1.SelectedDates.Add(targetDate);
    }
    TextView1.Text = "Selection Count ="
       + Calendar1.SelectedDates.Count.ToString();
}
Protected Sub Command1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim currentDay As Integer = Calendar1.VisibleDate.Day
    Dim currentMonth As Integer = Calendar1.VisibleDate.Month
    Dim currentYear As Integer = Calendar1.VisibleDate.Year
    Calendar1.SelectedDates.Clear()
    
    ' Loop through current month and add all Wednesdays to the collection.
    Dim i As Integer
    For i = 1 To System.DateTime.DaysInMonth(currentYear, currentMonth)
        Dim targetDate As New DateTime(currentYear, currentMonth, i)
        If targetDate.DayOfWeek = DayOfWeek.Wednesday Then
            Calendar1.SelectedDates.Add(targetDate)
        End If
    Next i
    TextView1.Text = "Selection Count = " & Calendar1.SelectedDates.Count.ToString()
End Sub

注釈

このプロパティは、コントロール内の選択した日付のコレクションを Calendar 表します。

適用対象

こちらもご覧ください