次の方法で共有


ListControlDesigner クラス

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

この型のすべてのメンバの一覧については、ListControlDesigner メンバ を参照してください。

System.Object
   System.ComponentModel.Design.ComponentDesigner
      System.Web.UI.Design.HtmlControlDesigner
         System.Web.UI.Design.ControlDesigner
            System.Web.UI.Design.WebControls.ListControlDesigner

Public Class ListControlDesigner
   Inherits ControlDesigner
   Implements IDataSourceProvider
[C#]
public class ListControlDesigner : ControlDesigner,
   IDataSourceProvider
[C++]
public __gc class ListControlDesigner : public ControlDesigner,
   IDataSourceProvider
[JScript]
public class ListControlDesigner extends ControlDesigner implements
   IDataSourceProvider

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

使用例

[Visual Basic] SimpleRadioButtonListDesigner という名前のクラスを ListControlDesigner クラスから継承して作成するコードの例を次に示します。このデザイナ クラスは GetDesignTimeHtml メソッド、 Initialize メソッド、および OnDataSourceChanged メソッドをオーバーライドします。このデザイナ クラスはデザイン画面に SimpleRadioButtonList クラスを表示します。

 
' Create a designer class, named 
' SimpleRadioButtonListDesigner, that provides
' design-time support for a custom list class.  
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Diagnostics
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design

    <System.Security.Permissions.SecurityPermission( _
     System.Security.Permissions.SecurityAction.Demand, _
     Flags:= System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Public Class SimpleRadioButtonListDesigner
        Inherits ListControlDesigner
        
        Private simpleRadioButtonList As SimpleRadioButtonList
        Private changedDataSource As Boolean 
        
        Public Sub New()

        End Sub
        ' Create HTML to display the control
        ' on the design surface.
        Overrides Public Function GetDesignTimeHtml() As String
            
            Dim designTimeHtml As String
            
            ' 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 property values and render HTML
            ' 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 new data source: " & DataSource ".")
                End If

                designTimeHtml = MyBase.GetDesignTimeHtml()
            
            ' Catch any exceptions that occur.
            Catch ex As Exception
                MyBase.GetErrorDesignTimeHtml(ex)
            
            ' Set the properties to original state.
            Finally
                simpleRadioButtonList.BackColor = oldBackColor
                items.Clear()
            End Try
            
            Return designTimeHtml
        End Function
        
        ' Ensure that only a SampleList control can be created in this
        ' designer.
        Public Overrides Sub Initialize(component As IComponent)
            Debug.Assert( _
                TypeOf component Is SimpleRadioButtonList, _
                "Invalid SimpleRadioButtonList Control initialized.")
      
            simpleRadioButtonList = CType(component, SimpleRadioButtonList)
            MyBase.Initialize(component)
        End Sub 
        
        ' If the data source changes, set
        ' a Boolean variable to true.
        Overrides Public Sub OnDataSourceChanged()
            changedDataSource = True
        End Sub
    End Class
End Namespace

[Visual Basic] DesignerAttribute クラスを使用して、 SimpleRadioButtonList クラスをそのデザイナ (SimpleRadioButtonListDesigner クラス) に関連付けるコード例を次に示します。

 
Imports System.Web.UI.WebControls
Imports System.ComponentModel

Namespace Examples.AspNet

    ' Create a class, named SimpleRadioButtonList,
    ' that uses the SimpleRadioButtonListDesigner
    ' to display its contents at design time. 
    <DesignerAttribute(GetType(Examples.AspNet.Design.SimpleRadioButtonListDesigner))> _
    Public Class SimpleRadioButtonList
        Inherits RadioButtonList
        
        ' Enter code here for a customized
        ' RadioButtonList class.
        
    End Class
End Namespace

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Web.UI.Design.WebControls

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Design (System.Design.dll 内)

参照

ListControlDesigner メンバ | System.Web.UI.Design.WebControls 名前空間