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

ListControlDesigner クラス

ListControl 抽象クラスから派生したコントロールVisual Web Designerデザイン時に使用できるようにする、デザイナ基本クラスとして機能します

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

Public Class ListControlDesigner
    Inherits DataBoundControlDesigner
Dim instance As ListControlDesigner
public class ListControlDesigner : DataBoundControlDesigner
public ref class ListControlDesigner : public
 DataBoundControlDesigner
public class ListControlDesigner extends DataBoundControlDesigner
public class ListControlDesigner extends
 DataBoundControlDesigner
解説解説

Visual Web Designer で、ソース ビューからデザイン ビュー切り替えると、ListControl クラスから派生したコントロール記述するマークアップソース コード解析されコントロールデザインバージョンデザイン サーフェイス作成されます。元のソース ビュー切り替えると、デザイン時のコントロールマークアップソース コード保持されWeb ページマークアップ反映されます。ListControlDesigner クラスは、ListControl から派生したコントロールVisual Web Designerデザイン時に使用できるようにする、デザイナ基本クラスとして機能します

ListControlDesigner クラスプロパティは、次の機能提供します

ListControlDesigner クラスメソッドは、次の機能提供します

使用例使用例

このセクションには、2 つコード例用意されています。最初コード例は、カスタム コントロール デザイナ派生する方法示してます。2 番目のコード例は、派生したコントロールデザイナ関連付ける方法示してます。

SimpleRadioButtonListDesigner という名前のクラスを、ListControlDesigner クラスから継承して作成する方法次のコード例示しますSimpleRadioButtonListDesigner クラスは、GetDesignTimeHtml メソッドInitialize メソッド、および OnDataSourceChanged メソッドオーバーライドます。SimpleRadioButtonListDesigner クラスは、デザイン サーフェイスSimpleRadioButtonList コントロール表示します

Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Diagnostics
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls

Namespace Examples.VB.WebControls.Design

    ' Create the SimpleRadioButtonListDesigner, which provides
    ' design-time support for a custom list class.  
    Public Class SimpleRadioButtonListDesigner
        Inherits ListControlDesigner

        Private simpleRadioButtonList As SimpleRadioButtonList
        Private changedDataSource As Boolean

        ' Create the markup to display the control on the design surface.
        Public Overrides Function
 GetDesignTimeHtml() As String

            Dim designTimeHtml As String
 = String.Empty

            ' Create variables to access the control's
            ' item collection and back color. 
            Dim items As ListItemCollection
 = simpleRadioButtonList.Items
            Dim oldBackColor As Color = simpleRadioButtonList.BackColor

            ' Check the property values and render the markup
            ' on the design surface accordingly.
            Try
                If (Color.op_Equality(oldBackColor, Color.Empty))
 Then
                    simpleRadioButtonList.BackColor = Color.Gainsboro
                End If

                If (changedDataSource) Then
                    items.Add( _
                        "Updated to a new data source: "
 & DataSource & ".")
                End If

                designTimeHtml = MyBase.GetDesignTimeHtml()

            Catch ex As Exception
                ' Catch any exceptions that occur.
                MyBase.GetErrorDesignTimeHtml(ex)

            Finally
                ' Set the properties back to their original state.
                simpleRadioButtonList.BackColor = oldBackColor
                items.Clear()
            End Try

            Return designTimeHtml
        End Function ' GetDesignTimeHtml

        Public Overrides Sub
 Initialize(ByVal component As IComponent)

            ' Ensure that only a SimpleRadioButtonList can be created
 
            ' in this designer.
            Debug.Assert( _
                TypeOf component Is SimpleRadioButtonList,
 _
                "An invalid SimpleRadioButtonList control was
 initialized.")

            simpleRadioButtonList = CType(component, SimpleRadioButtonList)
            MyBase.Initialize(component)
        End Sub ' Initialize

        ' If the data source changes, set a Boolean variable.
        Public Overrides Sub
 OnDataSourceChanged()
            changedDataSource = True
        End Sub ' OnDataSourceChanged
    End Class ' SimpleRadioButtonListDesigner
End Namespace ' Examples.VB.WebControls.Design
using System;
using System.ComponentModel;
using System.Drawing;
using System.Diagnostics;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;

namespace Examples.CS.WebControls.Design
{
    // Create the SimpleRadioButtonListDesigner, which provides
    // design-time support for a custom list class.
    public class SimpleRadioButtonListDesigner
 : ListControlDesigner
    {
        SimpleRadioButtonList simpleRadioButtonList;
        bool changedDataSource;

        // Create the markup to display the control on the design surface.
 
        public override string GetDesignTimeHtml()
        {
            string designTimeMarkup = null;

            // Create variables to access the control
            // item collection and back color.
            ListItemCollection items = simpleRadioButtonList.Items;
            Color oldBackColor = simpleRadioButtonList.BackColor;

            // Check the property values and render the markup
            // on the design surface accordingly.
            try
            {
                if (oldBackColor == Color.Empty)
                    simpleRadioButtonList.BackColor = Color.Gainsboro;

                if (changedDataSource)
                    items.Add("Updated to a new data source:
 " + 
                        DataSource + ".");

                // Call the base method to generate the markup.
                designTimeMarkup = base.GetDesignTimeHtml();
            }
            catch (Exception ex)
            {
                // Catch any exceptions that occur.
                designTimeMarkup = GetErrorDesignTimeHtml(ex);
            }
            finally
            {
                // Set the properties back to their original state.
                simpleRadioButtonList.BackColor = oldBackColor;
                items.Clear();
            }

            return designTimeMarkup;
        } // GetDesignTimeHtml

        public override void Initialize(IComponent
 component)
        {
            // Ensure that only a SimpleRadioButtonList can be 
            // created in this designer.
            Debug.Assert( 
                component is SimpleRadioButtonList, 
                "An invalid SimpleRadioButtonList control was initialized.");

            simpleRadioButtonList = (SimpleRadioButtonList)component;
            base.Initialize(component);
        } // Initialize

        // If the data source changes, set a boolean variable.
        public override void OnDataSourceChanged()
        {
            changedDataSource = true;
        } // OnDataSourceChanged
    } // SimpleRadioButtonListDesigner
} // Examples.CS.WebControls.Design

RadioButtonList コントロールかSimpleRadioButtonList コントロール派生するコード例次に示します。このコード例では、DesignerAttribute クラス使用してSimpleRadioButtonList コントロールをそのデザイナである SimpleRadioButtonListDesigner クラス関連付ける方法示してます。

Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The SimpleRadioButtonList is a copy of the RadioButtonList.
    ' It uses the SimpleRadioButtonListDesigner for design-time support.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <DesignerAttribute(GetType(Examples.VB.WebControls.Design.
 _
        SimpleRadioButtonListDesigner))> _
    <DataBindingHandler(GetType(Examples.VB.WebControls.Design.
 _
        SimpleRadioButtonListDataBindingHandler))> _
    Public Class SimpleRadioButtonList
        Inherits RadioButtonList
    End Class ' SimpleRadioButtonList
End Namespace ' Examples.VB.WebControls.Design
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Security.Permissions;

namespace Examples.CS.WebControls.Design
{
    // The SimpleRadioButtonList is a copy of the RadioButtonList.
    // It uses the SimpleRadioButtonListDesigner for design-time support.
    [AspNetHostingPermission(SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [Designer(typeof(Examples.CS.WebControls.Design.
       SimpleRadioButtonListDesigner))]
    [DataBindingHandler(typeof(Examples.CS.WebControls.Design.
        SimpleRadioButtonListDataBindingHandler))]
    public class SimpleRadioButtonList : RadioButtonList
    {
    } // SimpleRadioButtonList
} // Examples.CS.WebControls.Design
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.ComponentModel.Design.ComponentDesigner
     System.Web.UI.Design.HtmlControlDesigner
       System.Web.UI.Design.ControlDesigner
         System.Web.UI.Design.WebControls.BaseDataBoundControlDesigner
           System.Web.UI.Design.WebControls.DataBoundControlDesigner
            System.Web.UI.Design.WebControls.ListControlDesigner
               System.Web.UI.Design.WebControls.BulletedListDesigner
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ListControlDesigner メンバ
System.Web.UI.Design.WebControls 名前空間
ListControl
DataBoundControl
DataBoundControlDesigner クラス
BaseDataBoundControl
BaseDataBoundControlDesigner クラス
WebControl
ControlDesigner クラス
その他の技術情報
ASP.NET コントロール デザイナ概要
チュートリアル : Web サーバー コントロール用の基本的なコントロール デザイナ作成



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

辞書ショートカット

すべての辞書の索引

「ListControlDesigner クラス」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS