ControlCollection.AddAt(Int32, Control) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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 컨트롤을 지정하지 않습니다.
index 매개 변수가 0보다 작거나 속성보다 큽니다Count.
읽기 ControlCollection 전용입니다.
예제
다음 코드 예제에서는 메서드를 AddAt 사용하여 명명된 새 LiteralControl 이름을 ChildControl2 만들고 인덱스 위치 1에서 컨트롤의 myButton 컬렉션에 추가 ControlCollection 합니다.
// 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 서버 컨트롤의 인스턴스, 사용자가 만든 사용자 지정 서버 컨트롤 또는 리터럴 컨트롤일 수 있습니다.