PanelContainerDesigner.Initialize(IComponent) 方法

定义

准备设计器以查看、编辑和设计关联的控件。

public:
 override void Initialize(System::ComponentModel::IComponent ^ component);
public override void Initialize(System.ComponentModel.IComponent component);
override this.Initialize : System.ComponentModel.IComponent -> unit
Public Overrides Sub Initialize (component As IComponent)

参数

component
IComponent

Panel个 ,它实现一个 IComponent

例外

component 不是 Panel 派生自 Panel的类。

示例

下面的代码示例演示如何重写 Initialize 从类继承的类中的方法,以更改在设计时派生自 PanelContainerDesigner 类的 Panel 控件的行为。 如果关联的控件不是ArgumentException对象,该示例将MyPanelContainer引发异常。

// Initialize the designer.
public override void Initialize(IComponent component)
{
    // Ensure that only a MyPanelContainer can be created 
    // in this designer.
    if (!(component is MyPanelContainer))
        throw new ArgumentException();
    
    base.Initialize(component);
} // Initialize
' Initialize the designer.
Public Overrides Sub Initialize(ByVal component As IComponent)

    ' Ensure that only a MyPanelContainer can be created   
    ' in this designer. 
    If Not TypeOf component Is MyPanelContainer Then
        Throw New ArgumentException()
    End If

    MyBase.Initialize(component)

End Sub

注解

视觉对象设计器在准备好使用设计器呈现控件时调用 Initialize 该方法 PanelInitialize及其基本方法配置属性并设置设计器操作所需的事件。

参数 componentPanel 与此设计器或控件副本 Panel 关联的控件。

适用于

另请参阅