DataListDesigner クラスとは? わかりやすく解説

DataListDesigner クラス

DataList Web サーバー コントロールデザイン時の動作拡張します。

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

Public Class DataListDesigner
    Inherits BaseDataListDesigner
Dim instance As DataListDesigner
public class DataListDesigner : BaseDataListDesigner
public ref class DataListDesigner : public
 BaseDataListDesigner
public class DataListDesigner extends BaseDataListDesigner
public class DataListDesigner extends
 BaseDataListDesigner
使用例使用例

DataListDesigner クラス拡張する方法次のコード例示しますまた、このコードは、GetDesignTimeHtml メソッドオーバーライドして、DataList コントロール有効なときに紫色の 5 ポイント境界線表示します

Imports System
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Security
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports Microsoft.VisualBasic

Namespace ASPNET.Examples
    < _
        Designer("ASPNET.Examples.Design.SimpleGridViewDesigner",
 _
            "System.Web.UI.Design.GridViewDesigner")
 _
    > _
    Public Class SimpleGridView
        Inherits GridView

        ' Code to customize your GridView goes here

    End Class
End Namespace

Namespace ASPNET.Examples.Design
    <Permissions.SecurityPermission( _
    Permissions.SecurityAction.Demand, _
    Flags:=Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Public Class SimpleGridViewDesigner
        Inherits GridViewDesigner

        Private simpleGView As SimpleGridView

        Public Overrides Function
 GetDesignTimeHtml() As String
            Dim designTimeHtml As String
 = String.Empty

            simpleGView = CType(Component, SimpleGridView)

            ' Check the control's BorderStyle property to  
            ' conditionally render design-time HTML.
            If (simpleGView.BorderStyle = BorderStyle.NotSet)
 Then
                ' Save the current property settings in variables.
                Dim oldCellPadding As Integer
 = simpleGView.CellPadding
                Dim oldBorderWidth As Unit
 = simpleGView.BorderWidth
                Dim oldBorderColor As Color
 = simpleGView.BorderColor

                ' Set properties and generate the design-time HTML.
                Try
                    simpleGView.Caption = "SimpleGridView"
                    simpleGView.CellPadding = 1
                    simpleGView.BorderWidth = Unit.Pixel(3)
                    simpleGView.BorderColor = Color.Red

                    designTimeHtml = MyBase.GetDesignTimeHtml()

                Catch ex As Exception
                    ' Get HTML from the GetErrorDesignTimeHtml 
                    ' method if an exception occurs.
                    designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Return the properties to their original values.
                Finally
                    simpleGView.CellPadding = oldCellPadding
                    simpleGView.BorderWidth = oldBorderWidth
                    simpleGView.BorderColor = oldBorderColor
                End Try

            Else
                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If

            Return designTimeHtml
        End Function

        Protected Overrides Function
 _
            GetErrorDesignTimeHtml(ByVal exc As
 Exception) As String

            Return CreatePlaceHolderDesignTimeHtml( _
                "ASPNET.Examples: An error occurred while rendering
 the GridView.")

        End Function

        Public Overrides Sub
 Initialize(ByVal component As IComponent)

            simpleGView = CType(component, SimpleGridView)

            MyBase.Initialize(component)

        End Sub
    End Class
End Namespace
using System;
using System.Drawing;
using System.Security.Permissions;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;

<br /><span space="preserve">...</span><br />namespace
 ASPNET.Examples.CS
{
    [SecurityPermission( 
    SecurityAction.Demand, 
    Flags = SecurityPermissionFlag.UnmanagedCode)] 
    public class SimpleGridViewDesigner : GridViewDesigner
    {
        private SimpleGridView simpleGView;

        public override string GetDesignTimeHtml()
        {
            string designTimeHtml = String.Empty;

            simpleGView = (SimpleGridView)Component;

            // Check the control's BorderStyle property to  
            // conditionally render design-time HTML.
            if (simpleGView.BorderStyle == BorderStyle.NotSet)
            {
                // Save the current property settings in variables.
                int oldCellPadding = simpleGView.CellPadding;
                Unit oldBorderWidth = simpleGView.BorderWidth;
                Color oldBorderColor = simpleGView.BorderColor;

                // Set properties and generate the design-time HTML.
                try
                {
                    simpleGView.Caption = "SimpleGridView";
                    simpleGView.CellPadding = 1;
                    simpleGView.BorderWidth = Unit.Pixel(3);
                    simpleGView.BorderColor = Color.Red;

                    designTimeHtml = base.GetDesignTimeHtml();
                }
                catch (Exception ex)
                {
                    // Get HTML from the GetErrorDesignTimeHtml 
                    // method if an exception occurs.
                    designTimeHtml = GetErrorDesignTimeHtml(ex);

                    // Return the properties to their original values.
                }
                finally
                {
                    simpleGView.CellPadding = oldCellPadding;
                    simpleGView.BorderWidth = oldBorderWidth;
                    simpleGView.BorderColor = oldBorderColor;
                }
            }
            else
                designTimeHtml = base.GetDesignTimeHtml();

            return designTimeHtml;
        }

        protected override string
            GetErrorDesignTimeHtml(System.Exception exc)
        {
            return CreatePlaceHolderDesignTimeHtml(
                "ASPNET.Examples: An error occurred while
 rendering the GridView.");

        }

        public override void Initialize(IComponent
 component)
        {
            simpleGView = (SimpleGridView)component;
            base.Initialize(component);
        }
    }
}

DesignerAttribute を使用してデザイナDataList コントロール関連付ける方法次のコード例示します

< _
    Designer("ASPNET.Examples.Design.SimpleGridViewDesigner",
 _
        "System.Web.UI.Design.GridViewDesigner") _
> _
Public Class SimpleGridView
    Inherits GridView

    ' Code to customize your GridView goes here

End Class
[ Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", 
        "System.Web.UI.Design.GridViewDesigner")]
public class SimpleGridView : GridView
{
    // Code to customize your GridView goes here
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.TemplatedControlDesigner
           System.Web.UI.Design.WebControls.BaseDataListDesigner
            System.Web.UI.Design.WebControls.DataListDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「DataListDesigner クラス」の関連用語

DataListDesigner クラスのお隣キーワード
検索ランキング

   

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



DataListDesigner クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS