This documentation is archived and is not being maintained.

ListControlDesigner Class

Extends design-time behavior for ListControl Web server controls.

For a list of all members of this type, see ListControlDesigner Members.


[Visual Basic]
Public Class ListControlDesigner
   Inherits ControlDesigner
   Implements IDataSourceProvider
public class ListControlDesigner : ControlDesigner,
public __gc class ListControlDesigner : public ControlDesigner,
public class ListControlDesigner extends ControlDesigner implements

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


[Visual Basic] The following code example creates a class named SimpleRadioButtonListDesigner that inherits from the ListControlDesigner class. This designer class overrides the GetDesignTimeHtml method, the Initialize method, and the OnDataSourceChanged method. The designer class displays a SimpleRadioButtonList class on the design surface.

[Visual Basic] 
' 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.
                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
            ' Set the properties to original state.
                simpleRadioButtonList.BackColor = oldBackColor
            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)
        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] The following code example uses the DesignerAttribute class to associate the SimpleRadioButtonList class with its designer, the SimpleRadioButtonListDesigner class.

[Visual Basic] 
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] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Web.UI.Design.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Design (in System.Design.dll)

See Also

ListControlDesigner Members | System.Web.UI.Design.WebControls Namespace