ParentControlDesigner Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Extends the design mode behavior of a Control that supports nested controls.

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

Public Class ParentControlDesigner
	Inherits ControlDesigner


Initializes a new instance of the ParentControlDesigner class.


Gets the AccessibleObject assigned to the control.(Inherited from ControlDesigner.)


Gets the design-time action lists supported by the component associated with the designer.(Inherited from ComponentDesigner.)


Gets a value indicating whether selected controls will be re-parented.


Gets a value indicating whether a generic drag box should be drawn when dragging a toolbox item over the designer's surface.


Gets a value indicating whether the z-order of dragged controls should be maintained when dropped on a ParentControlDesigner.


Gets the collection of components associated with the component managed by the designer.(Inherited from ControlDesigner.)


This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets a value indicating whether resize handle allocation depends on the value of the AutoSize property. (Inherited from ControlDesigner.)


Gets the BehaviorService from the design environment.(Inherited from ControlDesigner.)


Gets the component this designer is designing.(Inherited from ComponentDesigner.)


Gets the control that the designer is designing.(Inherited from ControlDesigner.)


Gets the default location for a control added to the designer.


Gets or sets a value indicating whether a grid should be drawn on the control for this designer.


Gets a value indicating whether drag rectangles are drawn by the designer.(Overrides ControlDesigner.EnableDragRect.)


Gets or sets the size of each square of the grid that is drawn when the designer is in grid draw mode.


Gets the System.ComponentModel.InheritanceAttribute of the designer.(Inherited from ControlDesigner.)


Gets a value indicating whether this component is inherited.(Inherited from ComponentDesigner.)


Gets a value indicating whether the designer has a valid tool during a drag operation.


Gets the parent component for the ControlDesigner.(Inherited from ControlDesigner.)


Gets a value indicating whether the ControlDesigner will allow snapline alignment during a drag operation.(Inherited from ControlDesigner.)


Gets the selection rules that indicate the movement capabilities of a component.(Inherited from ControlDesigner.)


Gets a collection of property values that override user settings.(Inherited from ComponentDesigner.)


Gets a list of SnapLine objects representing significant alignment points for this control. (Overrides ControlDesigner.SnapLines.)


Gets the design-time verbs supported by the component that is associated with the designer.(Inherited from ComponentDesigner.)


Adds padding snaplines.


Processes Windows messages.(Inherited from ControlDesigner.)


This API supports the product infrastructure and is not intended to be used directly from your code. Called when a component is added to the parent container.


Indicates if this designer's control can be parented by the control of the specified designer.(Inherited from ControlDesigner.)


Indicates whether the specified control can be a child of the control managed by this designer.


Indicates whether the control managed by the specified designer can be a child of the control managed by this designer.


Creates a component or control from the specified tool and adds it to the current design document.

System_CAPS_protmethodCreateTool(ToolboxItem, Point)

Creates a component or control from the specified tool and adds it to the current design document at the specified location.

System_CAPS_protmethodCreateTool(ToolboxItem, Rectangle)

Creates a component or control from the specified tool and adds it to the current design document within the bounds of the specified rectangle.

System_CAPS_protmethodCreateToolCore(ToolboxItem, Int32, Int32, Int32, Int32, Boolean, Boolean)

Provides core functionality for all the CreateTool methods.


Provides default processing for Windows messages.(Inherited from ControlDesigner.)


Displays information about the specified exception to the user.(Inherited from ControlDesigner.)


Releases all resources used by the ComponentDesigner.(Inherited from ComponentDesigner.)


Releases the unmanaged resources used by the ParentControlDesigner, and optionally releases the managed resources.(Overrides ControlDesigner.Dispose(Boolean).)


Creates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location.(Inherited from ComponentDesigner.)

System_CAPS_protmethodEnableDesignMode(Control, String)

Enables design time functionality for a child control.(Inherited from ControlDesigner.)


Enables or disables drag-and-drop support for the control being designed.(Inherited from ControlDesigner.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Attempts to free resources by calling Dispose(false) before the object is reclaimed by garbage collection.(Inherited from ComponentDesigner.)


Gets the control from the designer of the specified component.


Gets a body glyph that represents the bounds of the control. (Overrides ControlDesigner.GetControlGlyph(GlyphSelectionType).)


Gets a collection of Glyph objects representing the selection borders and grab handles for a standard control.(Overrides ControlDesigner.GetGlyphs(GlyphSelectionType).)


Serves as the default hash function. (Inherited from Object.)


Indicates whether a mouse click at the specified point should be handled by the control.(Inherited from ControlDesigner.)


Used by deriving classes to determine if it returns the control being designed or some other Container while adding a component to it.


Attempts to retrieve the specified type of service from the design mode site of the designer's component.(Inherited from ComponentDesigner.)


Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodGetUpdatedRect(Rectangle, Rectangle, Boolean)

Updates the position of the specified rectangle, adjusting it for grid alignment if grid alignment mode is enabled.


Routes messages from the child controls of the specified control to the designer.(Inherited from ControlDesigner.)


Initializes the designer with the specified component.(Overrides ControlDesigner.Initialize(IComponent).)


Re-initializes an existing component.(Inherited from ControlDesigner.)


Initializes a newly created component.(Overrides ControlDesigner.InitializeNewComponent(IDictionary).)


Obsolete. Initializes the settings for an imported component that is already initialized to settings other than the defaults.(Inherited from ComponentDesigner.)


Returns the internal control designer with the specified index in the ControlDesigner.(Inherited from ControlDesigner.)

System_CAPS_protmethodSystem_CAPS_staticInvokeCreateTool(ParentControlDesigner, ToolboxItem)

Creates a tool from the specified ToolboxItem.


Gets the InheritanceAttribute of the specified ComponentDesigner.(Inherited from ComponentDesigner.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns the number of internal control designers in the ControlDesigner.(Inherited from ControlDesigner.)

System_CAPS_protmethodOnContextMenu(Int32, Int32)

Shows the context menu and provides an opportunity to perform additional processing when the context menu is about to be displayed.(Inherited from ControlDesigner.)


Provides an opportunity to perform additional processing immediately after the control handle has been created.(Inherited from ControlDesigner.)


Called in order to clean up a drag-and-drop operation.(Overrides ControlDesigner.OnDragComplete(DragEventArgs).)


Called when a drag-and-drop object is dropped onto the control designer view.(Overrides ControlDesigner.OnDragDrop(DragEventArgs).)


Called when a drag-and-drop operation enters the control designer view.(Overrides ControlDesigner.OnDragEnter(DragEventArgs).)


Called when a drag-and-drop operation leaves the control designer view.(Overrides ControlDesigner.OnDragLeave(EventArgs).)


Called when a drag-and-drop object is dragged over the control designer view.(Overrides ControlDesigner.OnDragOver(DragEventArgs).)


Receives a call when a drag-and-drop operation is in progress to provide visual cues based on the location of the mouse while a drag operation is in progress.(Inherited from ControlDesigner.)

System_CAPS_protmethodOnMouseDragBegin(Int32, Int32)

Called in response to the left mouse button being pressed and held while over the component.(Overrides ControlDesigner.OnMouseDragBegin(Int32, Int32).)


Called at the end of a drag-and-drop operation to complete or cancel the operation.(Overrides ControlDesigner.OnMouseDragEnd(Boolean).)

System_CAPS_protmethodOnMouseDragMove(Int32, Int32)

Called for each movement of the mouse during a drag-and-drop operation.(Overrides ControlDesigner.OnMouseDragMove(Int32, Int32).)


Receives a call when the mouse first enters the control.(Inherited from ControlDesigner.)


Receives a call after the mouse hovers over the control.(Inherited from ControlDesigner.)


Receives a call when the mouse first enters the control.(Inherited from ControlDesigner.)


Called when the control that the designer is managing has painted its surface so the designer can paint any additional adornments on top of the control.(Overrides ControlDesigner.OnPaintAdornments(PaintEventArgs).)


Obsolete. Called when the designer is intialized.(Inherited from ControlDesigner.)


Provides an opportunity to change the current mouse cursor.(Overrides ControlDesigner.OnSetCursor().)


Allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor.(Inherited from ComponentDesigner.)


Allows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor.(Inherited from ComponentDesigner.)


Allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor.(Inherited from ComponentDesigner.)


Allows a designer to add to the set of attributes that it exposes through a TypeDescriptor.(Inherited from ComponentDesigner.)


Allows a designer to add to the set of events that it exposes through a TypeDescriptor.(Inherited from ComponentDesigner.)


Adjusts the set of properties the component will expose through a TypeDescriptor.(Overrides ControlDesigner.PreFilterProperties(IDictionary).)

System_CAPS_protmethodRaiseComponentChanged(MemberDescriptor, Object, Object)

Notifies the IComponentChangeService that this component has been changed.(Inherited from ComponentDesigner.)


Notifies the IComponentChangeService that this component is about to be changed.(Inherited from ComponentDesigner.)


Returns a string that represents the current object.(Inherited from Object.)


Routes messages for the children of the specified control to each control rather than to a parent designer.(Inherited from ControlDesigner.)


Processes Windows messages and optionally routes them to the control.(Inherited from ControlDesigner.)


Specifies the accessibility object for the designer.(Inherited from ControlDesigner.)


For a description of this member, see the IDesignerFilter.PostFilterAttributes method.(Inherited from ComponentDesigner.)


For a description of this member, see the IDesignerFilter.PostFilterEvents method.(Inherited from ComponentDesigner.)


For a description of this member, see the IDesignerFilter.PostFilterProperties method.(Inherited from ComponentDesigner.)


For a description of this member, see the IDesignerFilter.PreFilterAttributes method.(Inherited from ComponentDesigner.)


For a description of this member, see the IDesignerFilter.PreFilterEvents method.(Inherited from ComponentDesigner.)


For a description of this member, see the IDesignerFilter.PreFilterProperties method.(Inherited from ComponentDesigner.)


For a description of this member, see the ITreeDesigner.Children property.(Inherited from ComponentDesigner.)


For a description of this member, see the ITreeDesigner.Parent property.(Inherited from ComponentDesigner.)

ParentControlDesigner provides a base class for designers of controls that can contain child controls. In addition to the methods and functionality inherited from the ControlDesigner and ComponentDesigner classes, ParentControlDesigner enables child controls to be added to, removed from, selected within, and arranged within the control whose behavior it extends at design time.

You can associate a designer with a type using a DesignerAttribute. For an overview of customizing design time behavior, see Extending Design-Time Support.

The following example demonstrates how to implement a custom ParentControlDesigner. This code example is part of a larger example provided for the IToolboxUser interface.

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Diagnostics
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

' This example contains an IRootDesigner that implements the IToolboxUser interface.
' This example demonstrates how to enable the GetToolSupported method of an IToolboxUser
' designer in order to disable specific toolbox items, and how to respond to the 
' invocation of a ToolboxItem in the ToolPicked method of an IToolboxUser implementation.
' This example component class demonstrates the associated IRootDesigner which 
' implements the IToolboxUser interface. When designer view is invoked, Visual 
' Studio .NET attempts to display a design mode view for the class at the top 
' of a code file. This can sometimes fail when the class is one of multiple types 
' in a code file, and has a DesignerAttribute associating it with an IRootDesigner. 
' Placing a derived class at the top of the code file solves this problem. A 
' derived class is not typically needed for this reason, except that placing the 
' RootDesignedComponent class in another file is not a simple solution for a code 
' example that is packaged in one segment of code.

Public Class RootViewSampleComponent
    Inherits RootDesignedComponent
End Class

' The following attribute associates the SampleRootDesigner with this example component.
<DesignerAttribute(GetType(SampleRootDesigner), GetType(IRootDesigner))> _
Public Class RootDesignedComponent
    Inherits System.Windows.Forms.Control
End Class

' This example IRootDesigner implements the IToolboxUser interface and provides a 
' Windows Forms view technology view for its associated component using an internal 
' Control type.     
' The following ToolboxItemFilterAttribute enables the GetToolSupported method of this
' IToolboxUser designer to be queried to check for whether to enable or disable all 
' ToolboxItems which create any components whose type name begins with "System.Windows.Forms".
<ToolboxItemFilterAttribute("System.Windows.Forms", ToolboxItemFilterType.Custom)> _
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class SampleRootDesigner
    Inherits ParentControlDesigner
    Implements IRootDesigner, IToolboxUser

    ' Member field of custom type RootDesignerView, a control that is shown in the 
    ' design mode document window. This member is cached to reduce processing needed 
    ' to recreate the view control on each call to GetView().
    Private m_view As RootDesignerView

    ' This string array contains type names of components that should not be added to 
    ' the component managed by this designer from the Toolbox.  Any ToolboxItems whose 
    ' type name matches a type name in this array will be marked disabled according to  
    ' the signal returned by the IToolboxUser.GetToolSupported method of this designer.
    Private blockedTypeNames As String() = {"System.Windows.Forms.ListBox", "System.Windows.Forms.GroupBox"}

    ' IRootDesigner.SupportedTechnologies is a required override for an IRootDesigner.
    ' This designer provides a display using the Windows Forms view technology.
    ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies
            Return New ViewTechnology() {ViewTechnology.Default}
        End Get
    End Property

    ' This method returns an object that provides the view for this root designer. 
    Function GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView
        ' If the design environment requests a view technology other than Windows 
        ' Forms, this method throws an Argument Exception.
        If technology <> ViewTechnology.Default Then
            Throw New ArgumentException("An unsupported view technology was requested", "Unsupported view technology.")
        End If

        ' Creates the view object if it has not yet been initialized.
        If m_view Is Nothing Then
            m_view = New RootDesignerView(Me)
        End If
        Return m_view
    End Function

    ' This method can signal whether to enable or disable the specified
    ' ToolboxItem when the component associated with this designer is selected.
    Function GetToolSupported(ByVal tool As ToolboxItem) As Boolean Implements IToolboxUser.GetToolSupported
        ' Search the blocked type names array for the type name of the tool
        ' for which support for is being tested. Return false to indicate the
        ' tool should be disabled when the associated component is selected.
        Dim i As Integer
        For i = 0 To blockedTypeNames.Length - 1
            If tool.TypeName = blockedTypeNames(i) Then
                Return False
            End If
        Next i ' Return true to indicate support for the tool, if the type name of the
        ' tool is not located in the blockedTypeNames string array.
        Return True
    End Function

    ' This method can perform behavior when the specified tool has been invoked.
    ' Invocation of a ToolboxItem typically creates a component or components, 
    ' and adds any created components to the associated component.
    Sub ToolPicked(ByVal tool As ToolboxItem) Implements IToolboxUser.ToolPicked
    End Sub

    ' This control provides a Windows Forms view technology view object that 
    ' provides a display for the SampleRootDesigner.
    <DesignerAttribute(GetType(ParentControlDesigner), GetType(IDesigner))> _
    Friend Class RootDesignerView
        Inherits Control
        ' This field stores a reference to a designer.
        Private m_designer As IDesigner

        Public Sub New(ByVal designer As IDesigner)
            ' Performs basic control initialization.
            m_designer = designer
            BackColor = Color.Blue
            Font = New Font(Font.FontFamily.Name, 24.0F)
        End Sub

        ' This method is called to draw the view for the SampleRootDesigner.
        Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
            ' Draws the name of the component in large letters.
            pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, New RectangleF(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height))
        End Sub
    End Class
End Class

.NET Framework
Available since 1.1

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

Return to top