Export (0) Print
Expand All

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

The ControlDesigner type exposes the following members.

  NameDescription
Public methodControlDesignerInitializes a new instance of the ControlDesigner class.
Top

  NameDescription
Public propertyAccessibilityObjectGets the AccessibleObject assigned to the control.
Public propertyActionListsGets the design-time action lists supported by the component associated with the designer. (Inherited from ComponentDesigner.)
Public propertyAssociatedComponentsGets the collection of components associated with the component managed by the designer. (Overrides ComponentDesigner.AssociatedComponents.)
Public propertyAutoResizeHandlesInfrastructure. Gets or sets a value indicating whether resize handle allocation depends on the value of the AutoSize property.
Protected propertyBehaviorServiceGets the BehaviorService from the design environment.
Public propertyComponentGets the component this designer is designing. (Inherited from ComponentDesigner.)
Public propertyControlGets the control that the designer is designing.
Protected propertyEnableDragRectGets a value indicating whether drag rectangles can be drawn on this designer component.
Protected propertyInheritanceAttributeGets the System.ComponentModel.InheritanceAttribute of the designer. (Overrides ComponentDesigner.InheritanceAttribute.)
Protected propertyInheritedGets a value indicating whether this component is inherited. (Inherited from ComponentDesigner.)
Protected propertyParentComponentGets the parent component for the ControlDesigner. (Overrides ComponentDesigner.ParentComponent.)
Public propertyParticipatesWithSnapLinesGets a value indicating whether the ControlDesigner will allow snapline alignment during a drag operation.
Public propertySelectionRulesGets the selection rules that indicate the movement capabilities of a component.
Protected propertyShadowPropertiesGets a collection of property values that override user settings. (Inherited from ComponentDesigner.)
Public propertySnapLinesGets a list of SnapLine objects representing significant alignment points for this control.
Public propertyVerbsGets the design-time verbs supported by the component that is associated with the designer. (Inherited from ComponentDesigner.)
Top

  NameDescription
Protected methodBaseWndProcProcesses Windows messages.
Public methodCanBeParentedToIndicates if this designer's control can be parented by the control of the specified designer.
Protected methodDefWndProcProvides default processing for Windows messages.
Protected methodDisplayErrorDisplays information about the specified exception to the user.
Public methodDispose()Releases all resources used by the ComponentDesigner. (Inherited from ComponentDesigner.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the ControlDesigner and optionally releases the managed resources. (Overrides ComponentDesigner.Dispose(Boolean).)
Public methodDoDefaultActionCreates 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.)
Protected methodEnableDesignModeEnables design time functionality for a child control.
Protected methodEnableDragDropEnables or disables drag-and-drop support for the control being designed.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAttempts to free resources by calling Dispose(false) before the object is reclaimed by garbage collection. (Inherited from ComponentDesigner.)
Protected methodGetControlGlyphReturns a ControlBodyGlyph representing the bounds of this control.
Public methodGetGlyphsGets a collection of Glyph objects representing the selection borders and grab handles for a standard control.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodGetHitTestIndicates whether a mouse click at the specified point should be handled by the control.
Protected methodGetServiceAttempts to retrieve the specified type of service from the design mode site of the designer's component. (Inherited from ComponentDesigner.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodHookChildControlsRoutes messages from the child controls of the specified control to the designer.
Public methodInitializeInitializes the designer with the specified component. (Overrides ComponentDesigner.Initialize(IComponent).)
Public methodInitializeExistingComponentRe-initializes an existing component. (Overrides ComponentDesigner.InitializeExistingComponent(IDictionary).)
Public methodInitializeNewComponentInitializes a newly created component. (Overrides ComponentDesigner.InitializeNewComponent(IDictionary).)
Public methodInitializeNonDefault Obsolete. Initializes the settings for an imported component that is already initialized to settings other than the defaults. (Inherited from ComponentDesigner.)
Public methodInternalControlDesignerReturns the internal control designer with the specified index in the ControlDesigner.
Protected methodInvokeGetInheritanceAttributeGets the InheritanceAttribute of the specified ComponentDesigner. (Inherited from ComponentDesigner.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodNumberOfInternalControlDesignersReturns the number of internal control designers in the ControlDesigner.
Protected methodOnContextMenuShows the context menu and provides an opportunity to perform additional processing when the context menu is about to be displayed.
Protected methodOnCreateHandleProvides an opportunity to perform additional processing immediately after the control handle has been created.
Protected methodOnDragCompleteReceives a call to clean up a drag-and-drop operation.
Protected methodOnDragDropReceives a call when a drag-and-drop object is dropped onto the control designer view.
Protected methodOnDragEnterReceives a call when a drag-and-drop operation enters the control designer view.
Protected methodOnDragLeaveReceives a call when a drag-and-drop operation leaves the control designer view.
Protected methodOnDragOverReceives a call when a drag-and-drop object is dragged over the control designer view.
Protected methodOnGiveFeedbackReceives 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.
Protected methodOnMouseDragBeginReceives a call in response to the left mouse button being pressed and held while over the component.
Protected methodOnMouseDragEndReceives a call at the end of a drag-and-drop operation to complete or cancel the operation.
Protected methodOnMouseDragMoveReceives a call for each movement of the mouse during a drag-and-drop operation.
Protected methodOnMouseEnterReceives a call when the mouse first enters the control.
Protected methodOnMouseHoverReceives a call after the mouse hovers over the control.
Protected methodOnMouseLeaveReceives a call when the mouse first enters the control.
Protected methodOnPaintAdornmentsReceives 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.
Public methodOnSetComponentDefaults Obsolete. Called when the designer is intialized. (Overrides ComponentDesigner.OnSetComponentDefaults().)
Protected methodOnSetCursorReceives a call each time the cursor needs to be set.
Protected methodPostFilterAttributesAllows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPostFilterEventsAllows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPostFilterPropertiesAllows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPreFilterAttributesAllows a designer to add to the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPreFilterEventsAllows a designer to add to the set of events that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPreFilterPropertiesAdjusts the set of properties the component exposes through a TypeDescriptor. (Overrides ComponentDesigner.PreFilterProperties(IDictionary).)
Protected methodRaiseComponentChangedNotifies the IComponentChangeService that this component has been changed. (Inherited from ComponentDesigner.)
Protected methodRaiseComponentChangingNotifies the IComponentChangeService that this component is about to be changed. (Inherited from ComponentDesigner.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodUnhookChildControlsRoutes messages for the children of the specified control to each control rather than to a parent designer.
Protected methodWndProcProcesses Windows messages and optionally routes them to the control.
Top

  NameDescription
Protected fieldaccessibilityObjSpecifies the accessibility object for the designer.
Protected fieldStatic memberInvalidPointDefines a local Point that represents the values of an invalid Point.
Top

  NameDescription
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterAttributesFor a description of this member, see the IDesignerFilter.PostFilterAttributes method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterEventsFor a description of this member, see the IDesignerFilter.PostFilterEvents method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterPropertiesFor a description of this member, see the IDesignerFilter.PostFilterProperties method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterAttributesFor a description of this member, see the IDesignerFilter.PreFilterAttributes method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterEventsFor a description of this member, see the IDesignerFilter.PreFilterEvents method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterPropertiesFor a description of this member, see the IDesignerFilter.PreFilterProperties method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate propertyITreeDesigner.ChildrenFor a description of this member, see the ITreeDesigner.Children property. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate propertyITreeDesigner.ParentFor a description of this member, see the ITreeDesigner.Parent property. (Inherited from ComponentDesigner.)
Top

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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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