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

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

このメソッドは、カスタム クラスを Table コントロールから派生させる場合に、主にコントロールの開発者によって使用されます。
このメソッドは、Control 基本クラスの CreateControlCollection 実装をオーバーライドします。Table コントロールについては、CreateControlCollection は、現在の Table コントロールの TableRow コントロールだけを格納できる ControlCollection を常に返します。

カスタム サーバー コントロールの CreateControlCollection メソッドをオーバーライドし、Table の EmptyControlCollection クラスについて、常に新しいインスタンスが返されるようにする方法のコード例を次に示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page Language="VB" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom Table - CreateControlCollection - VB.NET Example</title> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom Table - CreateControlCollection - VB.NET Example</h3> <aspSample:CustomTableCreateControlCollection id="Table1" runat="server" GridLines="Both" CellPadding="4"> <asp:TableRow> <asp:TableCell>Row 0, Col 0</asp:TableCell> <asp:TableCell>Row 0, Col 1</asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell>Row 1, Col 0</asp:TableCell> <asp:TableCell>Row 1, Col 1</asp:TableCell> </asp:TableRow> </aspSample:CustomTableCreateControlCollection> </form> </body> </HTML> <br /><span space="preserve">...</span><br />Imports System.Web Imports System.Security.Permissions Namespace Samples.AspNet.VB.Controls <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class CustomTableCreateControlCollection Inherits System.Web.UI.WebControls.Table Protected Overrides Function CreateControlCollection() As System.Web.UI.ControlCollection ' Return a new EmptyControlCollection Return New System.Web.UI.EmptyControlCollection(Me) End Function End Class End Namespace
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page Language="C#" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom Table - CreateControlCollection - C# Example</title> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom Table - CreateControlCollection - C# Example</h3> <aspSample:CustomTableCreateControlCollection id="Table1" runat="server" GridLines="Both" CellPadding="4"> <asp:TableRow> <asp:TableCell>Row 0, Col 0</asp:TableCell> <asp:TableCell>Row 0, Col 1</asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell>Row 1, Col 0</asp:TableCell> <asp:TableCell>Row 1, Col 1</asp:TableCell> </asp:TableRow> </aspSample:CustomTableCreateControlCollection> </form> </body> </HTML> <br /><span space="preserve">...</span><br />using System.Web; using System.Security.Permissions; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class CustomTableCreateControlCollection : System.Web.UI.WebControls.Table { protected override System.Web.UI.ControlCollection CreateControlCollection() { // Return a new EmptyControlCollection return new System.Web.UI.EmptyControlCollection(this); } } }
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page Language="VJ#" AutoEventWireup="True" %> <HTML> <HEAD> <title>Custom Table - CreateControlCollection - VJ# Example</title> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom Table - CreateControlCollection - VJ# Example</h3> <aspSample:CustomTableCreateControlCollection id="Table1" runat="server" GridLines="Both" CellPadding="4"> <asp:TableRow> <asp:TableCell>Row 0, Col 0</asp:TableCell> <asp:TableCell>Row 0, Col 1</asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell>Row 1, Col 0</asp:TableCell> <asp:TableCell>Row 1, Col 1</asp:TableCell> </asp:TableRow> </aspSample:CustomTableCreateControlCollection> </form> </body> </HTML> <br /><span space="preserve">...</span><br />package Samples.AspNet.JSL.Controls; public class CustomTableCreateControlCollection extends System.Web.UI.WebControls.Table { protected System.Web.UI.ControlCollection CreateControlCollection() { // Return a new EmptyControlCollection return new System.Web.UI.EmptyControlCollection(this); } //CreateControlCollection } //CustomTableCreateControlCollection

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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