ControlCollection.AddAt(Int32, Control) 메서드

정의

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

public:
 virtual void AddAt(int index, System::Web::UI::Control ^ child);
public virtual void AddAt (int index, System.Web.UI.Control child);
abstract member AddAt : int * System.Web.UI.Control -> unit
override this.AddAt : int * System.Web.UI.Control -> unit
Public Overridable Sub AddAt (index As Integer, child As Control)

매개 변수

index
Int32

자식 컨트롤을 추가할 배열의 위치입니다.

child
Control

컬렉션에 추가할 Control입니다.

예외

child 매개 변수가 컨트롤을 지정하지 않는 경우

index 매개 변수가 0보다 작거나 Count 속성보다 큰 경우

ControlCollection이 읽기 전용인 경우

예제

다음 코드 예제에서는 AddAt 새 메서드 LiteralControl 라는 ChildControl2 에 추가 합니다 myButton 컨트롤의 ControlCollection 컬렉션의 인덱스 위치 1입니다.

// Create a LiteralControl and use the Add method to add it
// to a button's ControlCollection, then use the AddAt method
// to add another LiteralControl to the collection at the
// index location of 1.
LiteralControl myLiteralControl = new LiteralControl("ChildControl1");
myButton.Controls.Add(myLiteralControl);
myButton.Controls.AddAt(1,new LiteralControl("ChildControl2"));
Response.Write("<b>ChildControl2 is added at index 1</b>");

// Get the Index location of the myLiteralControl LiteralControl
// and write it to the page.
Response.Write("<br /><b>Index of the ChildControl myLiteralControl is " +
    "</b>" + myButton.Controls.IndexOf(myLiteralControl));
' Create a LiteralControl and use the Add method to add it
' to a button's ControlCollection, then use the AddAt method
' to add another LiteralControl to the collection at the
' index location of 1.
Dim myLiteralControl As LiteralControl =  _
    new LiteralControl("ChildControl1")
myButton.Controls.Add(myLiteralControl)
myButton.Controls.AddAt(1,new LiteralControl("ChildControl2"))
Response.Write("<b>ChildControl2 is added at index 1</b>")

' Get the Index location of the myLiteralControl LiteralControl
' and write it to the page.
Response.Write("<br /><b>Index of the ChildControl myLiteralControl is </b>" & _
                 myButton.Controls.IndexOf(myLiteralControl))

설명

추가 된 컨트롤에는 모든 ASP.NET 서버 컨트롤, 사용자 지정 서버 컨트롤을 만든 또는 리터럴 컨트롤의 인스턴스일 수 있습니다.

적용 대상

추가 정보