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 的派生类。

示例

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

// 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

注解

可视化设计器在准备好使用设计器呈现Panel控件时调用 Initialize 方法。 Initialize及其基方法配置属性并设置设计器操作所需的事件。

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

适用于

另请参阅