ControlDesigner Class

ControlDesigner Class

 

Extends the design mode behavior of a Control.

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


public class ControlDesigner : ComponentDesigner

NameDescription
System_CAPS_pubmethodControlDesigner()

Initializes a new instance of the ControlDesigner class.

NameDescription
System_CAPS_pubpropertyAccessibilityObject

Gets the AccessibleObject assigned to the control.

System_CAPS_pubpropertyActionLists

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

System_CAPS_pubpropertyAssociatedComponents

Gets the collection of components associated with the component managed by the designer.(Overrides ComponentDesigner.AssociatedComponents.)

System_CAPS_pubpropertyAutoResizeHandles

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.

System_CAPS_protpropertyBehaviorService

Gets the BehaviorService from the design environment.

System_CAPS_pubpropertyComponent

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

System_CAPS_pubpropertyControl

Gets the control that the designer is designing.

System_CAPS_protpropertyEnableDragRect

Gets a value indicating whether drag rectangles can be drawn on this designer component.

System_CAPS_protpropertyInheritanceAttribute
System_CAPS_protpropertyInherited

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

System_CAPS_protpropertyParentComponent

Gets the parent component for the ControlDesigner.(Overrides ComponentDesigner.ParentComponent.)

System_CAPS_pubpropertyParticipatesWithSnapLines

Gets a value indicating whether the ControlDesigner will allow snapline alignment during a drag operation.

System_CAPS_pubpropertySelectionRules

Gets the selection rules that indicate the movement capabilities of a component.

System_CAPS_protpropertyShadowProperties

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

System_CAPS_pubpropertySnapLines

Gets a list of SnapLine objects representing significant alignment points for this control.

System_CAPS_pubpropertyVerbs

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

NameDescription
System_CAPS_protmethodBaseWndProc(Message)

Processes Windows messages.

System_CAPS_pubmethodCanBeParentedTo(IDesigner)

Indicates if this designer's control can be parented by the control of the specified designer.

System_CAPS_protmethodDefWndProc(Message)

Provides default processing for Windows messages.

System_CAPS_protmethodDisplayError(Exception)

Displays information about the specified exception to the user.

System_CAPS_pubmethodDispose()

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

System_CAPS_protmethodDispose(Boolean)

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

System_CAPS_pubmethodDoDefaultAction()

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.

System_CAPS_protmethodEnableDragDrop(Boolean)

Enables or disables drag-and-drop support for the control being designed.

System_CAPS_pubmethodEquals(Object)

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

System_CAPS_protmethodFinalize()

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

System_CAPS_protmethodGetControlGlyph(GlyphSelectionType)

Returns a ControlBodyGlyph representing the bounds of this control.

System_CAPS_pubmethodGetGlyphs(GlyphSelectionType)

Gets a collection of Glyph objects representing the selection borders and grab handles for a standard control.

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_protmethodGetHitTest(Point)

Indicates whether a mouse click at the specified point should be handled by the control.

System_CAPS_protmethodGetService(Type)

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

System_CAPS_pubmethodGetType()

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

System_CAPS_protmethodHookChildControls(Control)

Routes messages from the child controls of the specified control to the designer.

System_CAPS_pubmethodInitialize(IComponent)

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

System_CAPS_pubmethodInitializeExistingComponent(IDictionary)

Re-initializes an existing component.(Overrides ComponentDesigner.InitializeExistingComponent(IDictionary).)

System_CAPS_pubmethodInitializeNewComponent(IDictionary)

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

System_CAPS_pubmethodInitializeNonDefault()

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

System_CAPS_pubmethodInternalControlDesigner(Int32)

Returns the internal control designer with the specified index in the ControlDesigner.

System_CAPS_protmethodInvokeGetInheritanceAttribute(ComponentDesigner)

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

System_CAPS_protmethodMemberwiseClone()

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

System_CAPS_pubmethodNumberOfInternalControlDesigners()

Returns the number of internal control designers in the 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.

System_CAPS_protmethodOnCreateHandle()

Provides an opportunity to perform additional processing immediately after the control handle has been created.

System_CAPS_protmethodOnDragComplete(DragEventArgs)

Receives a call to clean up a drag-and-drop operation.

System_CAPS_protmethodOnDragDrop(DragEventArgs)

Receives a call when a drag-and-drop object is dropped onto the control designer view.

System_CAPS_protmethodOnDragEnter(DragEventArgs)

Receives a call when a drag-and-drop operation enters the control designer view.

System_CAPS_protmethodOnDragLeave(EventArgs)

Receives a call when a drag-and-drop operation leaves the control designer view.

System_CAPS_protmethodOnDragOver(DragEventArgs)

Receives a call when a drag-and-drop object is dragged over the control designer view.

System_CAPS_protmethodOnGiveFeedback(GiveFeedbackEventArgs)

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.

System_CAPS_protmethodOnMouseDragBegin(Int32, Int32)

Receives a call in response to the left mouse button being pressed and held while over the component.

System_CAPS_protmethodOnMouseDragEnd(Boolean)

Receives a call at the end of a drag-and-drop operation to complete or cancel the operation.

System_CAPS_protmethodOnMouseDragMove(Int32, Int32)

Receives a call for each movement of the mouse during a drag-and-drop operation.

System_CAPS_protmethodOnMouseEnter()

Receives a call when the mouse first enters the control.

System_CAPS_protmethodOnMouseHover()

Receives a call after the mouse hovers over the control.

System_CAPS_protmethodOnMouseLeave()

Receives a call when the mouse first enters the control.

System_CAPS_protmethodOnPaintAdornments(PaintEventArgs)

Receives a call 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.

System_CAPS_pubmethodOnSetComponentDefaults()

Obsolete.Called when the designer is intialized.(Overrides ComponentDesigner.OnSetComponentDefaults().)

System_CAPS_protmethodOnSetCursor()

Receives a call each time the cursor needs to be set.

System_CAPS_protmethodPostFilterAttributes(IDictionary)

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

System_CAPS_protmethodPostFilterEvents(IDictionary)

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

System_CAPS_protmethodPostFilterProperties(IDictionary)

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

System_CAPS_protmethodPreFilterAttributes(IDictionary)

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

System_CAPS_protmethodPreFilterEvents(IDictionary)

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

System_CAPS_protmethodPreFilterProperties(IDictionary)

Adjusts the set of properties the component exposes through a TypeDescriptor.(Overrides ComponentDesigner.PreFilterProperties(IDictionary).)

System_CAPS_protmethodRaiseComponentChanged(MemberDescriptor, Object, Object)

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

System_CAPS_protmethodRaiseComponentChanging(MemberDescriptor)

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

System_CAPS_pubmethodToString()

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

System_CAPS_protmethodUnhookChildControls(Control)

Routes messages for the children of the specified control to each control rather than to a parent designer.

System_CAPS_protmethodWndProc(Message)

Processes Windows messages and optionally routes them to the control.

NameDescription
System_CAPS_protfieldaccessibilityObj

Specifies the accessibility object for the designer.

System_CAPS_protfieldSystem_CAPS_staticInvalidPoint

Defines a local Point that represents the values of an invalid Point.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PostFilterAttributes(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PostFilterEvents(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PostFilterProperties(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PreFilterAttributes(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PreFilterEvents(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDesignerFilter.PreFilterProperties(IDictionary)

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

System_CAPS_pubinterfaceSystem_CAPS_privpropertyITreeDesigner.Children

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

System_CAPS_pubinterfaceSystem_CAPS_privpropertyITreeDesigner.Parent

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

ControlDesigner provides a base class for designers of components that derive from Control. In addition to the methods and functionality inherited from the ComponentDesigner class, ControlDesigner provides additional methods to support extending and altering the behavior of an associated Control 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 ControlDesigner implementation demonstrates handling MouseEnter and MouseLeave events, drawing on a control from designer code, and using part of the IDesignerFilter interface to add a property for the control at design time. The following sample code contains a designer and a sample user control associated with the designer. To build this sample, compile the sample into a class library, add a reference to the library to a Windows Forms project, add the control to the Toolbox, and add an instance of the control to your form. When you point to the control, the inner outline of the perimeter of the control is highlighted, and the color used to draw the outline corresponds to the OutlineColor property that the designer has added to the properties listed for the control.

Add a reference to the System.Design assembly to compile the code example.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace ControlDesignerExample
{
    // ExampleControlDesigner is an example control designer that 
    // demonstrates basic functions of a ControlDesigner.
    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] 
    public class ExampleControlDesigner  : System.Windows.Forms.Design.ControlDesigner
    {
        // This boolean state reflects whether the mouse is over the control.
        private bool mouseover = false;
        // This color is a private field for the OutlineColor property.
        private Color lineColor = Color.White;

        // This color is used to outline the control when the mouse is 
        // over the control.
        public Color OutlineColor
        {
            get
            {
                return lineColor;
            }
            set
            {
                lineColor = value;
            }
        }

        public ExampleControlDesigner()
        {
        }

        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.
        protected override void OnMouseEnter()
        {
            this.mouseover = true;
            this.Control.Refresh();
        }    

        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.        
        protected override void OnMouseLeave()
        {
            this.mouseover = false;            
            this.Control.Refresh();
        }        

        // Draws an outline around the control when the mouse is 
        // over the control.    
        protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
        {
            if (this.mouseover)
            {
                pe.Graphics.DrawRectangle(
                    new Pen(new SolidBrush(this.lineColor), 6), 
                    0, 
                    0, 
                    this.Control.Size.Width, 
                    this.Control.Size.Height);
            }
        }

        // Adds a property to this designer's control at design time 
        // that indicates the outline color to use. 
        // The DesignOnlyAttribute ensures that the OutlineColor
        // property is not serialized by the designer.
        protected override void PreFilterProperties(System.Collections.IDictionary properties)
        {
            PropertyDescriptor pd = TypeDescriptor.CreateProperty(
                typeof(ExampleControlDesigner), 
                "OutlineColor",
                typeof(System.Drawing.Color),
                new Attribute[] { new DesignOnlyAttribute(true) });

            properties.Add("OutlineColor", pd);
        }
    }

    // This example control demonstrates the ExampleControlDesigner.
    [DesignerAttribute(typeof(ExampleControlDesigner))]
    public class ExampleControl : System.Windows.Forms.UserControl
    {        
        private System.ComponentModel.Container components = null;

        public ExampleControl()
        {
            components = new System.ComponentModel.Container();
        }

        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if( components != null )
                components.Dispose();
            }
            base.Dispose( disposing );
        }
    }
}

.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
Show:
© 2016 Microsoft