ControlCollection 클래스

정의

ASP.NET 서버 컨트롤을 사용할 수 있도록 하여 그 자식 컨트롤 목록을 관리하는 컬렉션 컨테이너를 제공합니다.

public ref class ControlCollection : System::Collections::ICollection
public class ControlCollection : System.Collections.ICollection
type ControlCollection = class
    interface ICollection
    interface IEnumerable
Public Class ControlCollection
Implements ICollection
상속
ControlCollection
파생
구현

예제

다음 코드 예제에서는 재정의 된 Control.CreateChildControls 두 컨트롤, 명명 된 사용자 지정 클래스의 두 인스턴스를 만드는 방법 ChildControl, 이라는 문자열 속성이 있는 Message합니다. 두 컨트롤에 추가 됩니다 만들어지면는 ControlCollection합니다. 합니다 Add 메서드는 이러한 컨트롤의이 버전을 포함 하는 클래스에 추가할 각 Control.CreateChildControls합니다. 합니다 ChildControlsCreated 속성이 true 이러한 컨트롤 불필요 하 게 다시 생성 되지 것입니다 있도록 합니다.


protected override void CreateChildControls()
{               
   // Creates a new ControlCollection. 
   this.CreateControlCollection();

   // Create child controls.
    ChildControl firstControl = new ChildControl();
   firstControl.Message = "FirstChildControl";

   ChildControl secondControl = new ChildControl();
   secondControl.Message = "SecondChildControl";
   
   Controls.Add(firstControl);
   Controls.Add(secondControl);

   // Prevent child controls from being created again.
   ChildControlsCreated = true;
}

Protected Overrides Sub CreateChildControls()
   ' Creates a new ControlCollection. 
   Me.CreateControlCollection()
   
   ' Create child controls.
   Dim firstControl As New ChildControl()
   firstControl.Message = "FirstChildControl"
   
   Dim secondControl As New ChildControl()
   secondControl.Message = "SecondChildControl"
   
   Controls.Add(firstControl)
   Controls.Add(secondControl)
   
   ' Prevent child controls from being created again.
   ChildControlsCreated = True
End Sub


설명

메서드와 속성에 액세스할 수 있습니다 합니다 ControlCollection 를 통해 클래스는 Control.Controls 속성입니다. 이후를 Control 클래스는 모든 ASP.NET 서버 컨트롤에 대 한 기본 클래스,이 속성을 상속 하는 모든 서버 컨트롤입니다.

컬렉션에 대 한 자세한 내용은 참조 하세요. 컬렉션 및 데이터 구조합니다.

생성자

ControlCollection(Control)

지정된 부모 서버 컨트롤에 대한 ControlCollection 클래스의 새 인스턴스를 초기화합니다.

속성

Count

지정된 ASP.NET 서버 컨트롤의 ControlCollection 개체에 있는 서버 컨트롤 수를 가져옵니다.

IsReadOnly

ControlCollection 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

ControlCollection 개체가 동기화되었는지 여부를 나타내는 값을 가져옵니다.

Item[Int32]

ControlCollection 개체의 지정된 인덱스 위치에서 서버 컨트롤에 대한 참조를 가져옵니다.

Owner

ControlCollection 개체가 들어 있는 ASP.NET 서버 컨트롤을 가져옵니다.

SyncRoot

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

메서드

Add(Control)

지정된 Control 개체를 컬렉션에 추가합니다.

AddAt(Int32, Control)

지정된 Control 개체를 컬렉션의 지정된 인덱스 위치에 추가합니다.

Clear()

현재 서버 컨트롤의 ControlCollection 개체에서 컨트롤을 모두 제거합니다.

Contains(Control)

지정된 서버 컨트롤이 부모 서버 컨트롤의 ControlCollection 개체에 있는지 여부를 확인합니다.

CopyTo(Array, Int32)

ControlCollection 개체에 저장된 자식 컨트롤을 Array에서 지정된 인덱스 위치의 시작 부분에 있는 Array 개체에 복사합니다.

Equals(Object)

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

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

ControlCollection 개체를 반복할 수 있는 열거자를 검색합니다.

GetHashCode()

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

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

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

(다음에서 상속됨 Object)
IndexOf(Control)

컬렉션에서 지정된 Control 개체의 인덱스를 검색합니다.

MemberwiseClone()

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

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

지정된 서버 컨트롤을 부모 서버 컨트롤의 ControlCollection 개체에서 제거합니다.

RemoveAt(Int32)

ControlCollection 개체에서 지정된 인덱스 위치의 자식 컨트롤을 제거합니다.

ToString()

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

(다음에서 상속됨 Object)

확장 메서드

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보