DataList.CreateControlStyle メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataList.CreateControlStyle メソッドの意味・解説 

DataList.CreateControlStyle メソッド

すべてのスタイル関連プロパティ実装するために DataList コントロール内部使用する既定スタイル オブジェクト作成します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Overrides Function
 CreateControlStyle As Style
Dim returnValue As Style

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

戻り値
コントロール既定スタイル プロパティ格納している TableStyle。

解説解説

CreateControlStyle メソッドは、カスタム実装DataList コントロールか派生させる場合に、主にコントロール開発者によって使用されます。

使用例使用例

カスタム サーバー コントロールCreateControlStyle メソッドオーバーライドして、常にグリッド線セル間隔空けずDataList コントロール表示する方法コード例次に示します

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls"
 Assembly="Samples.AspNet.VB"
 %>
<%@ Page language="vb" %>
<HTML>
  <HEAD>
    <title>Custom DataList - CreateControlStyle - VB Example</title>
    <script runat="server">
      Private Sub Page_Load(sender As
 Object, e As EventArgs)

        ' Create sample data for the DataList control.
        Dim dt As System.Data.DataTable = New
 System.Data.DataTable()
        Dim dr As System.Data.DataRow

        ' Create a new column named Column1, of type String.
        Dim col As New System.Data.DataColumn("Column1",
 GetType(String))
        ' Add the column to the DataTable.
        dt.Columns.Add(col)

        dr = dt.NewRow()
        dr(0) = "Hello"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr(0) = "DataList"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr(0) = "World"
        dt.Rows.Add(dr)

        ' Show the DataTable values in the DataList.
        DataList1.DataSource = dt
        DataList1.DataBind()

      End Sub ' Page_Load
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post"
 runat="server">
      <h3>Custom DataList - CreateControlStyle - VB Example</h3>

      <aspSample:CustomDataListCreateControlStyle id="DataList1"
 runat="server" BorderColor="#999999"
 BorderStyle="None" BackColor="White" CellPadding="3" GridLines="Vertical"
 BorderWidth="1px" Width="100px">

        <HeaderStyle Font-Bold="True" ForeColor="White"
 BackColor="#000084" />
        <HeaderTemplate>
          <asp:Label id="Label1" runat="server">Column1</asp:Label>
        </HeaderTemplate>

        <ItemStyle ForeColor="Black" BackColor="#EEEEEE"
 />
        <ItemTemplate>
          <asp:Label id="Label2" runat="server"><%#
 DataBinder.Eval(Container.DataItem, "Column1") %></asp:Label>
        </ItemTemplate>

        <AlternatingItemStyle BackColor="#DCDCDC"
 />
        <AlternatingItemTemplate>
          <asp:Label id="Label3" runat="server"><%#
 DataBinder.Eval(Container.DataItem, "Column1") %></asp:Label>
        </AlternatingItemTemplate>

      </aspSample:CustomDataListCreateControlStyle>

    </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
 CustomDataListCreateControlStyle
        Inherits System.Web.UI.WebControls.DataList

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

            ' Create a new TableStyle instance based on ViewState values.
            Dim style As New
 System.Web.UI.WebControls.TableStyle(ViewState)

            ' Show the GridLines horizontal with no CellSpacing.
            style.GridLines = System.Web.UI.WebControls.GridLines.Horizontal
            style.CellSpacing = 0

            ' Return the Style
            Return style
        End Function
    End Class
End Namespace
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls"
 Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<HTML>
  <HEAD>
    <title>Custom DataList - CreateControlStyle - C# Example</title>
    <script runat="server">
      private void Page_Load(object sender,
 System.EventArgs e)
      {
        // Create sample data for the DataList control.
        System.Data.DataTable dt = new System.Data.DataTable();
        System.Data.DataRow dr;
        dt.Columns.Add(new System.Data.DataColumn("Column1",
 typeof(String)));

        dr = dt.NewRow();
        dr[0] = "Hello";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "DataList";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "World";
        dt.Rows.Add(dr);

        // Show the DataTable values in the DataList.
        DataList1.DataSource = dt;
        DataList1.DataBind();
    }
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom DataList - CreateControlStyle - C# Example</h3>

      <aspSample:CustomDataListCreateControlStyle id="DataList1" runat="server"
 BorderColor="#999999" BorderStyle="None" BackColor="White"
 CellPadding="3" GridLines="Vertical" BorderWidth="1px" Width="100px">

        <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"
 />
        <HeaderTemplate>
          <asp:Label id="Label1" runat="server">Column1</asp:Label>
        </HeaderTemplate>

        <ItemStyle ForeColor="Black" BackColor="#EEEEEE" />
        <ItemTemplate>
          <asp:Label id="Label2" runat="server"><%#
 DataBinder.Eval(Container.DataItem, "Column1") %></asp:Label>
        </ItemTemplate>

        <AlternatingItemStyle BackColor="#DCDCDC" />
        <AlternatingItemTemplate>
          <asp:Label id="Label3" runat="server"><%#
 DataBinder.Eval(Container.DataItem, "Column1") %></asp:Label>
        </AlternatingItemTemplate>

      </aspSample:CustomDataListCreateControlStyle>

    </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 CustomDataListCreateControlStyle
 : System.Web.UI.WebControls.DataList
    {
        protected override System.Web.UI.WebControls.Style CreateControlStyle()
        {
            // Create a new TableStyle instance based on ViewState values.
            System.Web.UI.WebControls.TableStyle style = new System.Web.UI.WebControls.TableStyle(ViewState);
            
            // Show the GridLines horizontal with no CellSpacing.
            style.GridLines = System.Web.UI.WebControls.GridLines.Horizontal;
            style.CellSpacing = 0;

            // Return the Style
            return style;
        }
    }
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls"
 Assembly="Samples.AspNet.JSL" %>
<%@ Page language="VJ#" %>
<HTML>
  <HEAD>
    <title>Custom DataList - CreateControlStyle - VJ# Example</title>
    <script runat="server">
        
    private void Page_Load(Object sender, System.EventArgs
 e)
    {
        // Create sample data for the DataList control.
        System.Data.DataTable dt = new System.Data.DataTable();
        System.Data.DataRow dr;
        dt.get_Columns().Add(new System.Data.DataColumn("Column1",
 
            String.class.ToType()));

        dr = dt.NewRow();
        dr.set_Item(0, "Hello");
        dt.get_Rows().Add(dr);

        dr = dt.NewRow();
        dr.set_Item(0, "DataList");
        dt.get_Rows().Add(dr);

        dr = dt.NewRow();
        dr.set_Item(0, "World");
        dt.get_Rows().Add(dr);

        // Show the DataTable values in the DataList.
        DataList1.set_DataSource(dt);
        DataList1.DataBind();
    } //Page_Load
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom DataList - CreateControlStyle - VJ# Example</h3>

      <aspSample:CustomDataListCreateControlStyle id="DataList1" runat="server"
 BorderColor="#999999" BorderStyle="None" BackColor="White"
 CellPadding="3" GridLines="Vertical" BorderWidth="1px" Width="100px">

        <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"
 />
        <HeaderTemplate>
          <asp:Label id="Label1" runat="server">Column1</asp:Label>
        </HeaderTemplate>

        <ItemStyle ForeColor="Black" BackColor="#EEEEEE" />
        <ItemTemplate>
          <asp:Label id="Label2" runat="server"><%#
 DataBinder.Eval(Container.get_DataItem(), "Column1") %></asp:Label>
        </ItemTemplate>

        <AlternatingItemStyle BackColor="#DCDCDC" />
        <AlternatingItemTemplate>
          <asp:Label id="Label3" runat="server"><%#
 DataBinder.Eval(Container.get_DataItem(), "Column1") %></asp:Label>
        </AlternatingItemTemplate>

      </aspSample:CustomDataListCreateControlStyle>

    </form>
  </body>
</HTML>
<br /><span space="preserve">...</span><br />package
 Samples.AspNet.JSL.Controls;

public class CustomDataListCreateControlStyle
    extends System.Web.UI.WebControls.DataList
{
    protected System.Web.UI.WebControls.Style CreateControlStyle()
    {
        // Create a new TableStyle instance based on ViewState values.
        System.Web.UI.WebControls.TableStyle style = new System.Web.UI.
            WebControls.TableStyle(get_ViewState());
        // Show the GridLines horizontal with no CellSpacing.
        style.set_GridLines(System.Web.UI.WebControls.GridLines.Horizontal);
        style.set_CellSpacing(0);
        // Return the Style
        return style;
    } //CreateControlStyle
} //CustomDataListCreateControlStyle
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataList.CreateControlStyle メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataList.CreateControlStyle メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS