Export (0) Print
Expand All

TextControlDesigner.Initialize Method

.NET Framework 1.1

Initializes the designer with the specified component.

[Visual Basic]
Overrides Public Sub Initialize( _
   ByVal component As IComponent _
) Implements IDesigner.Initialize
[C#]
public override void Initialize(
 IComponent component
);
[C++]
public: void Initialize(
 IComponent* component
);
[JScript]
public override function Initialize(
   component : IComponent
);

Parameters

component
The IComponent associated with this designer.

Implements

IDesigner.Initialize

Example

[Visual Basic] The following code example shows a custom class, named CustomLabelDesigner, that derives from the LabelDesigner class. This class overrides the Initialize method to ensure that only objects that are instances of the CustomLabel class are created in the designer.

[Visual Basic] 
Imports System
Imports System.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design

    Public Class SampleLabelDesigner
        Inherits LabelDesigner
        
        ' Override the GetDesignTimeHtml method.
        Public Overrides Function GetDesignTimeHtml() As String

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

                ' Create variables to hold current property settings.
                Dim oldBorderStyle As BorderStyle = sampleLabel.BorderStyle
                    
               ' Set properties and the design-time HTML.
                Try
                    sampleLabel.BorderStyle = BorderStyle.Dashed
                    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
                    sampleLabel.BorderStyle = oldBorderStyle
                End Try
          
            Else
                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If
      
            Return designTimeHTML
        End Function
    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

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

.NET Framework Security: 

See Also

TextControlDesigner Class | TextControlDesigner Members | System.Web.UI.Design Namespace

Show:
© 2014 Microsoft