SelectedDatesCollection 클래스

정의

DateTime 컨트롤에서 선택한 날짜를 나타내는 Calendar 개체의 컬렉션을 캡슐화합니다. 이 클래스는 상속될 수 없습니다.

public ref class SelectedDatesCollection sealed : System::Collections::ICollection
public sealed class SelectedDatesCollection : System.Collections.ICollection
type SelectedDatesCollection = class
    interface ICollection
    interface IEnumerable
Public NotInheritable Class SelectedDatesCollection
Implements ICollection
상속
SelectedDatesCollection
구현

예제

다음 코드 예제에서는 프로그래밍 방식으로 사용 하는 방법에 설명 합니다 SelectedDatesCollection 에서 날짜를 선택 하는 클래스는 Calendar 제어 합니다.

<%@ Page Language="C#"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
  void Page_Load(Object sender, EventArgs e) 
  {
    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate;
  }

  void SelectButton_Click(Object sender, EventArgs e) 
  {

    int current_day = DisplayCalendar.VisibleDate.Day;
    int current_month = DisplayCalendar.VisibleDate.Month;
    int current_year = DisplayCalendar.VisibleDate.Year;

    DisplayCalendar.SelectedDates.Clear();
   
    // Iterate through the current month and add all Wednesdays to the 
    // SelectedDates collection of the Calendar control.
    for (int i = 1; i <= System.DateTime.DaysInMonth(current_year, current_month); i++)
    {
       DateTime currentDate = new DateTime(current_year, current_month, i);
       if (currentDate.DayOfWeek == DayOfWeek.Wednesday)
       {
         DisplayCalendar.SelectedDates.Add(currentDate);
       }
    }

     MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();
 
  }

  void DisplayCalendar_SelectionChanged(Object sender, EventArgs e) 
  {
    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString();
  }
 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
 
      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />
 
      <hr />
 
      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 
        
      <br/>
 
      <asp:label id="MessageLabel" 
        runat="server" />
 
    </form>
  </body>
</html>
<%@ Page Language="VB"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 
    DisplayCalendar.VisibleDate = DisplayCalendar.TodaysDate
    
  End Sub

  Sub SelectButton_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim current_day As Integer = DisplayCalendar.VisibleDate.Day
    Dim current_month As Integer = DisplayCalendar.VisibleDate.Month
    Dim current_year As Integer = DisplayCalendar.VisibleDate.Year

    DisplayCalendar.SelectedDates.Clear()
   
    ' Iterate through the current month and add all Wednesdays to the 
    ' SelectedDates collection of the Calendar control.
    Dim i As Integer
    For i = 1 To System.DateTime.DaysInMonth(current_year, current_month)
    
      Dim currentDate As New DateTime(current_year, current_month, i)
      If currentDate.DayOfWeek = DayOfWeek.Wednesday Then
       
        DisplayCalendar.SelectedDates.Add(currentDate)
        
      End If
      
    Next

    MessageLabel.Text = "Selection Count = " + DisplayCalendar.SelectedDates.Count.ToString()
 
  End Sub

  Sub DisplayCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
  
    MessageLabel.Text = "Selection Count = " & DisplayCalendar.SelectedDates.Count.ToString()
  
  End Sub
 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
 
      <asp:calendar id="DisplayCalendar" runat="server"  
        selectionmode="DayWeekMonth" 
        onselectionchanged="DisplayCalendar_SelectionChanged" />
 
      <hr />
 
      <asp:button id="SelectButton"
        text="Select All Weds in Month" 
        onclick="SelectButton_Click"  
        runat="server"/> 
        
      <br/>
 
      <asp:label id="MessageLabel" 
        runat="server" />
 
    </form>
  </body>
</html>

설명

이 클래스를 사용 하 여 프로그래밍 방식으로의 컬렉션을 관리할 System.DateTime 에서 선택한 날짜를 나타내는 개체를 Calendar 제어 합니다. 이 클래스는 추가 하거나 컬렉션에서 날짜를 제거 하려면 일반적으로 사용 됩니다.

이 컬렉션에는 날짜만 저장 합니다. 각각의 시간 부분은 System.DateTime 제거 됩니다. 날짜를 오름차순으로 정렬 저장 됩니다. 중복 된 날짜의 경우 하나의 날짜 컬렉션에 저장 됩니다.

생성자

SelectedDatesCollection(ArrayList)

지정된 날짜 목록을 사용하여 SelectedDatesCollection 클래스의 새 인스턴스를 초기화합니다.

속성

Count

SelectedDatesCollection 컬렉션의 DateTime 개체 수를 가져옵니다.

IsReadOnly

SelectedDatesCollection 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

SelectedDatesCollection 컬렉션에 대한 액세스가 동기화되는지 즉, 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다.

Item[Int32]

DateTime 컬렉션의 지정된 인덱스에 해당하는 SelectedDatesCollection 개체를 가져옵니다.

SyncRoot

SelectedDatesCollection 컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

메서드

Add(DateTime)

지정된 DateTime 개체를 SelectedDatesCollection 컬렉션의 끝에 추가합니다.

Clear()

컬렉션에서 모든 DateTime 개체를 제거합니다.

Contains(DateTime)

SelectedDatesCollection 컬렉션에 지정한 DateTime 개체가 있는지 여부를 나타내는 값을 반환합니다.

CopyTo(Array, Int32)

SelectedDatesCollection 컬렉션의 항목을 지정된 Array에 지정된 인덱스부터 시작하도록 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

IEnumerator 컬렉션에 모든 DateTime 개체를 포함하는 SelectedDatesCollection 구현 개체를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Remove(DateTime)

DateTime 컬렉션에서 지정된 SelectedDatesCollection 개체를 제거합니다.

SelectRange(DateTime, DateTime)

지정한 날짜 범위를 SelectedDatesCollection 컬렉션에 추가합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보