ControlCollection.AddAt(Int32, Control) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee voegt u het opgegeven Control object toe aan de verzameling op de opgegeven indexlocatie.
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)
Parameters
- index
- Int32
De locatie in de matrix waarop het onderliggende besturingselement moet worden toegevoegd.
Uitzonderingen
De child parameter geeft geen besturingselement op.
De index parameter is kleiner dan nul of groter dan de Count eigenschap.
Het ControlCollection is alleen-lezen.
Voorbeelden
In het volgende codevoorbeeld wordt de AddAt methode gebruikt om een nieuwe LiteralControl benoemde naam ChildControl2 te maken en deze toe te voegen aan de verzameling van ControlCollection het myButton besturingselement op de indexlocatie van 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))
Opmerkingen
Het toegevoegde besturingselement kan een exemplaar zijn van elk ASP.NET serverbeheer, een aangepast serverbeheer dat u maakt of een letterlijk besturingselement.