ControlDesigner クラス

定義

Control のデザイン モードの動作を拡張します。

public ref class ControlDesigner : System::ComponentModel::Design::ComponentDesigner
public class ControlDesigner : System.ComponentModel.Design.ComponentDesigner
type ControlDesigner = class
    inherit ComponentDesigner
Public Class ControlDesigner
Inherits ComponentDesigner
継承
ControlDesigner
派生

次の実装例では ControlDesigner 、処理 MouseEnterMouseLeave イベント、デザイナー コードからコントロールを描画する方法、およびインターフェイスの IDesignerFilter 一部を使用してデザイン時にコントロールのプロパティを追加する方法を示します。 次のサンプル コードには、デザイナーとデザイナーに関連付けられているサンプル ユーザー コントロールが含まれています。 このサンプルをビルドするには、サンプルをクラス ライブラリにコンパイルし、ライブラリへの参照をWindows フォーム プロジェクトに追加し、ツールボックスにコントロールを追加して、フォームにコントロールのインスタンスを追加します。 コントロールをポイントすると、コントロールの境界の内側のアウトラインが強調表示され、アウトラインの描画に使用される色は、デザイナーがコントロールの一覧のプロパティに追加したプロパティに対応 OutlineColor します。

コード例をコンパイルするために、System.Design アセンブリへの参照を追加します。

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Collections;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;
using namespace System::Security::Permissions;

   public ref class TestControlDesigner: public System::Windows::Forms::Design::ControlDesigner
   {
   private:
      bool mouseover;
      Color lineColor;

   public:

      property Color OutlineColor 
      {
         Color get()
         {
            return lineColor;
         }

         void set( Color value )
         {
            lineColor = value;
         }

      }
      TestControlDesigner()
      {
         mouseover = false;
         lineColor = Color::White;
      }

   protected:
      virtual void OnMouseEnter() override
      {
         this->mouseover = true;
         this->Control->Refresh();
      }

      virtual void OnMouseLeave() override
      {
         this->mouseover = false;
         this->Control->Refresh();
      }

      virtual void OnPaintAdornments( System::Windows::Forms::PaintEventArgs^ pe ) override
      {
         if ( this->mouseover )
                  pe->Graphics->DrawRectangle( gcnew Pen( gcnew SolidBrush( this->lineColor ),6 ), 0, 0, this->Control->Size.Width, this->Control->Size.Height );
      }

   protected:
      [ReflectionPermission(SecurityAction::Demand, Flags=ReflectionPermissionFlag::MemberAccess)]
      virtual void PreFilterProperties( System::Collections::IDictionary^ properties ) override
      {
         properties->Add( "OutlineColor", TypeDescriptor::CreateProperty( TestControlDesigner::typeid, "OutlineColor", System::Drawing::Color::typeid, nullptr ) );
      }
   };

   [DesignerAttribute(TestControlDesigner::typeid)]
   public ref class TestControl: public System::Windows::Forms::UserControl
   {
   private:
      System::ComponentModel::Container^ components;

   public:
      TestControl()
      {
         components = gcnew System::ComponentModel::Container;
      }

   protected:
      ~TestControl()
      {
         if ( components != nullptr )
         {
            delete components;
         }
      }
   };
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. 
    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 );
        }
    }
}
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Collections
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

Namespace ControlDesignerExample
    _
    ' ExampleControlDesigner is an example control designer that 
    ' demonstrates basic functions of a ControlDesigner.
    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
    Public Class ExampleControlDesigner
        Inherits System.Windows.Forms.Design.ControlDesigner

        ' This boolean state reflects whether the mouse is over the control.
        Private mouseover As Boolean = False
        ' This color is a private field for the OutlineColor property.
        Private lineColor As Color = Color.White

        ' This color is used to outline the control when the mouse is 
        ' over the control.
        Public Property OutlineColor() As Color
            Get
                Return lineColor
            End Get
            Set(ByVal Value As Color)
                lineColor = Value
            End Set
        End Property

        Public Sub New()
        End Sub

        ' Sets a value and refreshes the control's display when the 
        ' mouse position enters the area of the control.
        Protected Overrides Sub OnMouseEnter()
            Me.mouseover = True
            Me.Control.Refresh()
        End Sub

        ' Sets a value and refreshes the control's display when the 
        ' mouse position enters the area of the control.		
        Protected Overrides Sub OnMouseLeave()
            Me.mouseover = False
            Me.Control.Refresh()
        End Sub

        ' Draws an outline around the control when the mouse is 
        ' over the control.	
        Protected Overrides Sub OnPaintAdornments(ByVal pe As System.Windows.Forms.PaintEventArgs)
            If Me.mouseover Then
                pe.Graphics.DrawRectangle(New Pen(New SolidBrush(Me.lineColor), 6), 0, 0, Me.Control.Size.Width, Me.Control.Size.Height)
            End If
        End Sub

        ' 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 Overrides Sub PreFilterProperties(ByVal properties As System.Collections.IDictionary)
            Dim pd As PropertyDescriptor = TypeDescriptor.CreateProperty( _
            GetType(ExampleControlDesigner), _
            "OutlineColor", _
            GetType(System.Drawing.Color), _
            New Attribute() {New DesignOnlyAttribute(True)})

            properties.Add("OutlineColor", pd)
        End Sub
    End Class

    ' This example control demonstrates the ExampleControlDesigner.
    <DesignerAttribute(GetType(ExampleControlDesigner))> _
     Public Class ExampleControl
        Inherits System.Windows.Forms.UserControl
        Private components As System.ComponentModel.Container = Nothing

        Public Sub New()
            components = New System.ComponentModel.Container()
        End Sub

        Protected Overloads Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If (components IsNot Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    End Class

End Namespace

注釈

ControlDesigner は、 から Control派生するコンポーネントのデザイナーに基本クラスを提供します。 クラスから ComponentDesigner 継承されたメソッドと機能に加えて、 には、 ControlDesigner デザイン時に関連付けられている Control の動作の拡張と変更をサポートする追加のメソッドが用意されています。

デザイナーを 型に関連付けるには、 を DesignerAttribute使用します。 設計時の動作のカスタマイズの概要については、「 Design-Time サポートの拡張」を参照してください。

コンストラクター

ControlDesigner()

ControlDesigner クラスの新しいインスタンスを初期化します。

フィールド

accessibilityObj

デザイナーのアクセシビリティ オブジェクトを指定します。

InvalidPoint

無効な Point の値を表すローカルの Point を定義します。

プロパティ

AccessibilityObject

コントロールに割り当てられた AccessibleObject を取得します。

ActionLists

デザイナーに関連付けられているコンポーネントでサポートされているデザイン時アクション リストを取得します。

(継承元 ComponentDesigner)
AssociatedComponents

デザイナーで管理されているコンポーネントに関連付けられているコンポーネントのコレクションを取得します。

AutoResizeHandles

AutoSize プロパティの値に基づいてサイズ変更ハンドルを割り当てるかどうかを示す値を取得または設定します。

BehaviorService

デザイン環境から BehaviorService を取得します。

Component

デザイナーがデザインするコンポーネントを取得します。

(継承元 ComponentDesigner)
Control

デザイナーがデザインするコントロールを取得します。

EnableDragRect

ドラッグ四角形をこのデザイナー コンポーネントに描画できるかどうかを示す値を取得します。

InheritanceAttribute

デザイナーの InheritanceAttribute を取得します。

InheritanceAttribute

関連付けられているコンポーネントの継承の種類を示す属性を取得します。

(継承元 ComponentDesigner)
Inherited

コンポーネントが継承されているかどうかを示す値を取得します。

(継承元 ComponentDesigner)
ParentComponent

ControlDesigner の親コンポーネントを取得します。

ParentComponent

このデザイナーの親コンポーネントを取得します。

(継承元 ComponentDesigner)
ParticipatesWithSnapLines

ドラッグ操作中に ControlDesigner でスナップ線を配置できるかどうかを示す値を取得します。

SelectionRules

コンポーネントの移動機能を示す選択規則を取得します。

SetTextualDefaultProperty

Control のデザイン モードの動作を拡張します。

(継承元 ComponentDesigner)
ShadowProperties

ユーザー設定値をオーバーライドするプロパティ値のコレクションを取得します。

(継承元 ComponentDesigner)
SnapLines

このコントロールの有効な配置ポイントを表す SnapLine オブジェクトの一覧を取得します。

Verbs

デサイナに関連付けられているコンポーネントがサポートしているデザイン時の動詞を取得します。

(継承元 ComponentDesigner)

メソッド

BaseWndProc(Message)

Windows メッセージを処理します。

CanBeParentedTo(IDesigner)

このデザイナーのコントロールが、指定したデザイナーのコントロールを親として持つことができるかどうかを示します。

DefWndProc(Message)

Windows メッセージの既定の処理を提供します。

DisplayError(Exception)

指定した例外に関する情報をユーザーに表示します。

Dispose()

ComponentDesigner によって使用されているすべてのリソースを解放します。

(継承元 ComponentDesigner)
Dispose(Boolean)

ControlDesigner によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。

DoDefaultAction()

コンポーネントの既定イベントに対するメソッド シグネチャをソース コード ファイル内に作成し、コード内のその位置にカーソルを移動します。

(継承元 ComponentDesigner)
EnableDesignMode(Control, String)

子コントロールに対するデザイン時の機能を有効にします。

EnableDragDrop(Boolean)

デザイン中のコントロールに対して、ドラッグ アンド ドロップのサポートを有効または無効にします。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetControlGlyph(GlyphSelectionType)

このコントロールのバインドを表す ControlBodyGlyph を返します。

GetGlyphs(GlyphSelectionType)

標準コントロールの選択境界線とグラブ ハンドルを表す Glyph オブジェクトのコレクションを取得します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetHitTest(Point)

指定した点でのマウス クリックがコントロールによって処理されるかどうかを示します。

GetService(Type)

デザイナーのコンポーネントのデザイン モード サイトから、指定した型のサービスの取得を試みます。

(継承元 ComponentDesigner)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
HookChildControls(Control)

指定したコントロールの子コントロールからのメッセージをデザイナーにルーティングします。

Initialize(IComponent)

コンポーネントを指定して、デザイナーを初期化します。

InitializeExistingComponent(IDictionary)

既存のコンポーネントを再初期化します。

InitializeExistingComponent(IDictionary)

既存のコンポーネントを再初期化します。

(継承元 ComponentDesigner)
InitializeNewComponent(IDictionary)

新たに作成されたコンポーネントを初期化します。

InitializeNewComponent(IDictionary)

新たに作成されたコンポーネントを初期化します。

(継承元 ComponentDesigner)
InitializeNonDefault()

コントロールのプロパティを既定値以外の値に初期化します。

InitializeNonDefault()
古い.
古い.

既定値以外の値に既に初期化されている、インポートされたコンポーネントの設定値を初期化します。

(継承元 ComponentDesigner)
InternalControlDesigner(Int32)

ControlDesigner の指定されたインデックス位置の内部コントロール デザイナーを返します。

InvokeGetInheritanceAttribute(ComponentDesigner)

指定した InheritanceAttributeComponentDesigner を取得します。

(継承元 ComponentDesigner)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
NumberOfInternalControlDesigners()

ControlDesigner 内の内部コントロール デザイナーの数を返します。

OnContextMenu(Int32, Int32)

コンテキスト メニューを表示し、コンテキスト メニューが表示される直前に追加処理を実行する機会を提供します。

OnCreateHandle()

制御ハンドルが作成された直後に、追加処理を実行する機会を提供します。

OnDragComplete(DragEventArgs)

ドラッグ アンド ドロップ操作をクリーンアップするための呼び出しを受信します。

OnDragDrop(DragEventArgs)

ドラッグ アンド ドロップ オブジェクトがコントロールのデザイナー ビューにドロップされると呼び出しを受信します。

OnDragEnter(DragEventArgs)

ドラッグ アンド ドロップ操作がコントロールのデザイナー ビューに入ると呼び出しを受信します。

OnDragLeave(EventArgs)

ドラッグ アンド ドロップ操作がコントロールのデザイナー ビューを離れると呼び出しを受信します。

OnDragOver(DragEventArgs)

ドラッグ アンド ドロップ オブジェクトがコントロールのデザイナー ビュー上にドラッグされると呼び出しを受信します。

OnGiveFeedback(GiveFeedbackEventArgs)

ドラッグ アンド ドロップの操作中に呼び出しを受信し、ドラッグ操作のマウスの位置に基づいてビジュアル キューを提供します。

OnMouseDragBegin(Int32, Int32)

コンポーネント上でマウスの左ボタンをしばらく押したままにすると応答して呼び出しを受信します。

OnMouseDragEnd(Boolean)

ドラッグ アンド ドロップ操作の終了時に呼び出しを受信し、操作を完了またはキャンセルします。

OnMouseDragMove(Int32, Int32)

ドラッグ アンド ドロップ操作中にマウスが移動するたびに呼び出しを受信します。

OnMouseEnter()

マウスが最初にコントロールに入ると呼び出しを受信します。

OnMouseHover()

マウスがコントロールの上にあるときに呼び出しを受信します。

OnMouseLeave()

マウスが最初にコントロールに入ると呼び出しを受信します。

OnPaintAdornments(PaintEventArgs)

デザイナーが管理しているコントロールが表面を描画したときに呼び出しを受信し、デザイナーがコントロールの一番上に追加の表示要素を描画できるようにします。

OnSetComponentDefaults()
古い.
古い.

デザイナーが初期化されるときに呼び出されます。

OnSetCursor()

カーソルを設定する必要があるたびに呼び出しを受信します。

PostFilterAttributes(IDictionary)

デザイナーが、TypeDescriptor を通じて公開する一連の属性から、項目を変更または削除できるようにします。

(継承元 ComponentDesigner)
PostFilterEvents(IDictionary)

デザイナーが、TypeDescriptor を通じて公開する一連のイベントから、項目を変更または削除できるようにします。

(継承元 ComponentDesigner)
PostFilterProperties(IDictionary)

デザイナーが、TypeDescriptor を通じて公開する一連のプロパティから、項目を変更または削除できるようにします。

(継承元 ComponentDesigner)
PreFilterAttributes(IDictionary)

デザイナーが、TypeDescriptor を通じて公開する一連の属性に項目を追加できるようにします。

(継承元 ComponentDesigner)
PreFilterEvents(IDictionary)

デザイナーが、TypeDescriptor を通じて公開する一連のイベントに項目を追加できるようにします。

(継承元 ComponentDesigner)
PreFilterProperties(IDictionary)

TypeDescriptor を通じてコンポーネントが公開するプロパティのセットを調整します。

RaiseComponentChanged(MemberDescriptor, Object, Object)

コンポーネントが変更されたことを IComponentChangeService に通知します。

(継承元 ComponentDesigner)
RaiseComponentChanging(MemberDescriptor)

コンポーネントが変更されようとしていることを IComponentChangeService に通知します。

(継承元 ComponentDesigner)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
UnhookChildControls(Control)

指定したコントロールの子に対するメッセージを親デザイナーではなく各コントロールにルーティングします。

WndProc(Message)

Windows メッセージを処理し、必要に応じてコントロールにルーティングします。

明示的なインターフェイスの実装

IDesignerFilter.PostFilterAttributes(IDictionary)

このメンバーの説明については、PostFilterAttributes(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
IDesignerFilter.PostFilterEvents(IDictionary)

このメンバーの説明については、PostFilterEvents(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
IDesignerFilter.PostFilterProperties(IDictionary)

このメンバーの説明については、PostFilterProperties(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
IDesignerFilter.PreFilterAttributes(IDictionary)

このメンバーの説明については、PreFilterAttributes(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
IDesignerFilter.PreFilterEvents(IDictionary)

このメンバーの説明については、PreFilterEvents(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
IDesignerFilter.PreFilterProperties(IDictionary)

このメンバーの説明については、PreFilterProperties(IDictionary) メソッドのトピックを参照してください。

(継承元 ComponentDesigner)
ITreeDesigner.Children

このメンバーの説明については、Children プロパティを参照してください。

(継承元 ComponentDesigner)
ITreeDesigner.Parent

このメンバーの説明については、Parent プロパティを参照してください。

(継承元 ComponentDesigner)

適用対象

こちらもご覧ください