Export (0) Print
Expand All

ListControlDesigner Class

Extends design-time behavior for ListControl Web server controls.

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

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

[Visual Basic]
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

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.

Example

[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.
            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] 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.

Requirements

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

Show:
© 2014 Microsoft