This documentation is archived and is not being maintained.

CheckBoxDesigner Class

Extends design-time behavior for the CheckBox Web server control.

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

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

[Visual Basic]
Public Class CheckBoxDesigner
   Inherits ControlDesigner
[C#]
public class CheckBoxDesigner : ControlDesigner
[C++]
public __gc class CheckBoxDesigner : public ControlDesigner
[JScript]
public class CheckBoxDesigner extends ControlDesigner

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.

Remarks

The CheckBoxDesigner class overrides the GetDesignTimeHtml method of the ControlDesigner class to set any empty Text property on the control to ensure that the control is displayed with a meaningul representation at design-time. If the Text property is emptly, the GetDesignTimeHtml method of this class sets the Text property of the control to the Control.ID property of the control.

Example

[Visual Basic] The following code example creates a custom designer class, named SampleCheckBoxDesigner, that inherits from the CheckBoxDesigner class. It overrides the GetDesignTimeHtml method. If the CheckBox.Text property has not been set previously, a call to this method sets it to a string and displays that string on the design surface. If the Text property has been set, the existing property value is displayed.

[Visual Basic] 
' Create a class, named SampleCheckBoxDesigner, that 
' overrides the GetDesignTimeHtml method to display
' the control on the design surface.
Imports System
Imports System.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design

        ' Override the GetDesignTimeHtml method to display
        ' display a border on the control if the BorderStyle
        ' property has not been set by the user.
        <System.Security.Permissions.SecurityPermission( _
          System.Security.Permissions.SecurityAction.Demand, _
          Flags := System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
        Public Class SampleCheckBoxDesigner
            Inherits CheckBoxDesigner
        
            ' Override the GetDesignTimeHtml method.
            Public Overrides Function GetDesignTimeHtml() As String

                Dim sampleCheckBox As SampleCheckBox = CType(Component, SampleCheckBox)
                Dim designTimeHtml As String = Nothing
    
                ' Check the control's BorderStyle property
                ' to conditionally render design-time HTML.
                If (sampleCheckBox.BorderStyle = BorderStyle.NotSet) Then

                    ' Create variables to hold current property settings.
                    Dim oldBorderStyle As BorderStyle = sampleCheckBox.BorderStyle
                    
                   ' Set properties and the design-time HTML.
                    Try
                        sampleCheckBox.BorderStyle = BorderStyle.Groove
                    
                        designTimeHtml = MyBase.GetDesignTimeHtml()
                
                    ' If an exception occurs, call the GetErrorDesignTimeHtml
                    ' method.
                    Catch ex As Exception
                        designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Return properties to their original settings.
                    Finally
                        sampleCheckBox.BorderStyle = oldBorderStyle
                    End Try
          
                Else
                    designTimeHtml = MyBase.GetDesignTimeHtml()
                End If
      
                Return designTimeHTML
            End Function
    End Class
End Namespace

[Visual Basic] The following code example is a simple class, named SampleCheckBox, that inherits from the CheckBox class and is associated with the SampleCheckBoxDesigner class by the DesignerAttribute class.

[Visual Basic] 
' The SampleCheckBox class that uses the 
' SampleCheckBoxDesigner class.
<Designer(GetType( _
Examples.AspNet.Design.SampleCheckBoxDesigner))> _
Public Class SampleCheckBox
 Inherits CheckBox
   ' Include code here for custom
   ' CheckBox class.
End Class

[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

CheckBoxDesigner Members | System.Web.UI.Design.WebControls Namespace | CheckBox

Show: