Control.CreateControlCollection メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim returnValue As ControlCollection returnValue = Me.CreateControlCollection
現在のサーバー コントロールの子サーバー コントロールを格納する ControlCollection オブジェクト。

ControlCollection クラスから派生したコレクション オブジェクトを既に作成している場合には、カスタム サーバー コントロールのこのメソッドをオーバーライドします。このメソッドのオーバーライドでコレクション クラスをインスタンス化できます。

CreateControlCollection メソッドをオーバーライドして、ControlCollection クラスを継承する CustomControlCollection クラスのインスタンスを作成するコード例を次に示します。
' Override the CreateControlCollection method to ' write to the Trace object when tracing is enabled ' for the page or application in which this control ' is included. Protected Overrides Function CreateControlCollection() As ControlCollection Return New CustomControlCollection(Me) End Function
// Override the CreateControlCollection method to // write to the Trace object when tracing is enabled // for the page or application in which this control // is included. protected override ControlCollection CreateControlCollection() { return new CustomControlCollection(this); }
CreateChildControls メソッドのカスタム サーバー コントロール オーバーライドで CreateControlCollection メソッドを使用するコード例を次に示します。新しいコレクションが作成され、firstControl と secondControl の 2 つの子コントロールが設定されます。
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 'CreateChildControls
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; }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.CreateControlCollection メソッドを検索する場合は、下記のリンクをクリックしてください。

- Control.CreateControlCollection メソッドのページへのリンク