ListControlDesigner Class
Serves as the base class for designers that provide design-time support in the Visual Web Designer for controls that are derived from the ListControl abstract class.
Assembly: System.Design (in System.Design.dll)
In the Visual Web Designer, when the user switches from Source to Design view, the markup source code that describes a control derived from the ListControl class is parsed and a design-time version of the control is created on the design surface. When the user switches back to Source view, the design-time control is persisted to the markup source code and edited into the markup for the Web page. The ListControlDesigner class serves as the base class for designers that provide design-time support in the Visual Web Designer for controls that are derived from the ListControl.
The ListControlDesigner class properties provide the following functionality:
The ActionLists property returns a DesignerActionListCollection object, which typically contains an object that is derived from the DesignerActionList object for each level in the inheritance tree of the designer.
The DataTextField and DataValueField properties provide access to the corresponding properties of a control that is derived from the ListControl class. The DataTextField and DataValueField indicate the fields of the data source that provide the text and value content of the list items, respectively.
The ListControlDesigner class methods provide the following functionality:
The DataBind method binds the associated control that is derived from the ListControl to a design-time data source.
The GetDesignTimeHtml method returns the markup that is used to render the associated control at design time.
The GetSelectedDataSource method returns the design-time DataSource component from the associated control container.
The GetResolvedSelectedDataSource method returns the DataSource from the control container, resolved to the design-time DataMember property of the control.
The Initialize method prepares the designer to view and design the associated control that is derived from the ListControl.
The OnDataSourceChanged method is called when the DataSource for the associated control has changed.
The PreFilterProperties method is used to remove additional properties from, add additional properties to, or shadow properties of the associated control that is derived from the ListControl.
This section provides two code examples. The first demonstrates how to derive a custom control designer. The second demonstrates how to associate a derived control with a designer.
The following code example shows how to create a class named SimpleRadioButtonListDesigner that inherits from the ListControlDesigner class. The SimpleRadioButtonListDesigner class overrides the GetDesignTimeHtml, Initialize, and OnDataSourceChanged methods. The SimpleRadioButtonListDesigner class displays a SimpleRadioButtonList control on the design surface.
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
The following code example derives the SimpleRadioButtonList control from the RadioButtonList control, and shows how to use the DesignerAttribute class to associate the SimpleRadioButtonList control with its designer, the SimpleRadioButtonListDesigner class.
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
- SecurityPermission
for calling unmanaged code. Demand value: Demand. Permission value: UnmanagedCode
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
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.