ComponentEditorPage Class

Provides a base implementation for a ComponentEditorPage.

Namespace: System.Windows.Forms.Design
Assembly: System.Windows.Forms (in

<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public MustInherit Class ComponentEditorPage
	Inherits Panel
Dim instance As ComponentEditorPage

/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public abstract class ComponentEditorPage extends Panel
public abstract class ComponentEditorPage extends Panel
Not applicable.

The ComponentEditorPage class is a complete implementation for a component editor page that consists of an empty window. You can extend this page to add your own controls. ComponentEditorPage is used by a ComponentEditorForm of a WindowsFormsComponentEditor.

The following code example demonstrates an example ComponentEditorPage implementation.

' This example component editor page type provides an example 
' ComponentEditorPage implementation.
Friend Class ExampleComponentEditorPage
    Inherits System.Windows.Forms.Design.ComponentEditorPage
    Private l1 As Label
    Private b1 As Button
    Private pg1 As PropertyGrid

    ' Base64-encoded serialized image data for the required component editor page icon.

    Public Sub New()
        ' Initialize the page, which inherits from Panel, and its controls.
        Me.Size = New Size(400, 250)
        Me.Icon = DeserializeIconFromBase64Text(icondata)
        Me.Text = "Example Page"

        b1 = New Button
        b1.Size = New Size(200, 20)
        b1.Location = New Point(200, 0)
        b1.Text = "Set a random background color"
        AddHandler b1.Click, AddressOf Me.randomBackColor

        l1 = New Label
        l1.Size = New Size(190, 20)
        l1.Location = New Point(4, 2)
        l1.Text = "Example Component Editor Page"

        pg1 = New PropertyGrid
        pg1.Size = New Size(400, 280)
        pg1.Location = New Point(0, 30)
    End Sub

    ' This method indicates that the Help button should be enabled for this 
    ' component editor page.
    Public Overrides Function SupportsHelp() As Boolean
        Return True
    End Function

    ' This method is called when the Help button for this component editor page is pressed.
    ' This implementation uses the IHelpService to show the Help topic for a sample keyword.
    Public Overrides Sub ShowHelp()
        ' The GetSelectedComponent method of a ComponentEditorPage retrieves the
        ' IComponent associated with the WindowsFormsComponentEditor.
        Dim selectedComponent As IComponent = Me.GetSelectedComponent()

        ' Retrieve the Site of the component, and return if null.
        Dim componentSite As ISite = selectedComponent.Site
        If componentSite Is Nothing Then
        End If
        ' Acquire the IHelpService to display a help topic using a indexed keyword lookup.
        Dim helpService As IHelpService = CType(componentSite.GetService(GetType(IHelpService)), IHelpService)
        If (helpService IsNot Nothing) Then
        End If
    End Sub

    ' The LoadComponent method is raised when the ComponentEditorPage is displayed.
    Protected Overrides Sub LoadComponent()
        Me.pg1.SelectedObject = Me.Component
    End Sub

    ' The SaveComponent method is raised when the WindowsFormsComponentEditor is closing 
    ' or the current ComponentEditorPage is closing.
    Protected Overrides Sub SaveComponent()
    End Sub

    ' If the associated component is a Control, this method sets the BackColor to a random color.
    ' This method is invoked by the button on this ComponentEditorPage.
    Private Sub randomBackColor(ByVal sender As Object, ByVal e As EventArgs)
        If GetType(System.Windows.Forms.Control).IsAssignableFrom(CType(Me.Component, Object).GetType()) Then
            ' Sets the background color of the Control associated with the
            ' WindowsFormsComponentEditor to a random color.
            Dim rnd As New Random
            CType(Me.Component, System.Windows.Forms.Control).BackColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))
        End If
    End Sub

    ' This method can be used to retrieve an Icon from a block 
    ' of Base64-encoded text.
    Private Function DeserializeIconFromBase64Text(ByVal [text] As String) As icon
        Dim img As Icon = Nothing
        Dim memBytes As Byte() = Convert.FromBase64String([text])
        Dim formatter As New BinaryFormatter
        Dim stream As New MemoryStream(memBytes)
        img = CType(formatter.Deserialize(stream), Icon)
        Return img
    End Function
End Class


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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0