Freigeben über


TableCell.CreateControlStyle-Methode

Erstellt eine TableItemStyle-Klasse für das TableCell-Steuerelement.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Protected Overrides Function CreateControlStyle As Style
'Usage
Dim returnValue As Style

returnValue = Me.CreateControlStyle
protected override Style CreateControlStyle ()
protected:
virtual Style^ CreateControlStyle () override
protected Style CreateControlStyle ()
protected override function CreateControlStyle () : Style

Rückgabewert

Eine Style-Klasse, die die TableItemStyle-Klasse für das TableCell-Steuerelement darstellt.

Hinweise

Die von der CreateControlStyle-Methode erstellte TableItemStyle-Klasse wird mit den Eigenschaften Wrap, HorizontalAlign und VerticalAlign verwendet.

Die CreateControlStyle-Methode wird hauptsächlich von Entwicklern von Steuerelementen zum Erweitern der Funktionalität des TableCell-Steuerelements verwendet.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie die CreateControlStyle-Methode in einem benutzerdefinierten Serversteuerelement überschrieben wird, sodass immer eine neue Instanz der TableStyle-Klasse für die TableCell zurückgegeben wird.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom TableCell - CreateControlStyle - VB.NET Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom TableCell - CreateControlStyle - VB.NET Example</h3>
            
            <asp:Table id="Table1" runat="server" CellPadding="3" CellSpacing="2">
                <asp:TableRow>
                    <aspSample:CustomTableCellCreateControlStyle Text="(0,0)" />
                    <aspSample:CustomTableCellCreateControlStyle Text="(0,1)" />
                    <aspSample:CustomTableCellCreateControlStyle Text="(0,2)" />
                </asp:TableRow>
                <asp:TableRow>
                    <aspSample:CustomTableCellCreateControlStyle Text="(1,0)" />
                    <aspSample:CustomTableCellCreateControlStyle Text="(1,1)" />
                    <aspSample:CustomTableCellCreateControlStyle Text="(1,2)" />
                </asp:TableRow>
            </asp:Table>
        </form>
    </body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom TableCell - CreateControlStyle - C# Example</title>
  </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom TableCell - CreateControlStyle - C# Example</h3>
      
      <asp:Table id="Table1" 
        runat="server" 
        CellPadding="3" 
        CellSpacing="2">
        <asp:TableRow>
          <aspSample:CustomTableCellCreateControlStyle Text="(0,0)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(0,1)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(0,2)" />
        </asp:TableRow>
        <asp:TableRow>
          <aspSample:CustomTableCellCreateControlStyle Text="(1,0)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(1,1)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(1,2)" />
        </asp:TableRow>
      </asp:Table>
      
        </form>
    </body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom TableCell - CreateControlStyle - VJ# Example</title>
  </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom TableCell - CreateControlStyle - VJ# Example</h3>
      
      <asp:Table id="Table1" 
        runat="server" 
        CellPadding="3" 
        CellSpacing="2">
        <asp:TableRow>
          <aspSample:CustomTableCellCreateControlStyle Text="(0,0)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(0,1)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(0,2)" />
        </asp:TableRow>
        <asp:TableRow>
          <aspSample:CustomTableCellCreateControlStyle Text="(1,0)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(1,1)" />
          <aspSample:CustomTableCellCreateControlStyle Text="(1,2)" />
        </asp:TableRow>
      </asp:Table>
      
        </form>
    </body>
</HTML>
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomTableCellCreateControlStyle
        Inherits System.Web.UI.WebControls.TableCell

        Protected Overrides Function CreateControlStyle() As System.Web.UI.WebControls.Style

            ' Initializes and return a new instance of the TableStyle class.
            Return New System.Web.UI.WebControls.TableStyle(Me.ViewState)
        End Function
    End Class
End Namespace
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomTableCellCreateControlStyle : System.Web.UI.WebControls.TableCell
  {
    protected override System.Web.UI.WebControls.Style CreateControlStyle()
    {
      // Initializes and return a new instance of the TableStyle class.
      return new System.Web.UI.WebControls.TableStyle(this.ViewState);
    }
  }
}
package Samples.AspNet.JSL.Controls; 

public class CustomTableCellCreateControlStyle
    extends System.Web.UI.WebControls.TableCell
{
    protected System.Web.UI.WebControls.Style CreateControlStyle()
    {
        // Initializes and return a new instance of the TableStyle class.
        return new System.Web.UI.WebControls.TableStyle(this.get_ViewState());
    } //CreateControlStyle
} //CustomTableCellCreateControlStyle

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

TableCell-Klasse
TableCell-Member
System.Web.UI.WebControls-Namespace
Style-Klasse
TableItemStyle
Wrap
HorizontalAlign
VerticalAlign

Weitere Ressourcen

Table-, TableRow- und TableCell-Webserver-Steuerelemente