ListControlDesigner.Initialize(IComponent) 方法

定义

准备设计器,以查看、编辑和设计关联的组件。Prepares the designer to view, edit, and design the associated control.

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

ListControl 派生的控件实现 IComponentA control derived from the ListControl that implements an IComponent.

示例

下面的代码示例将重写 Initialize 从类派生的设计器中的方法 ListControlDesigner ,以确保 SimpleRadioButtonList 自定义设计器仅使用名为的控件类的实例。The following code example overrides the Initialize method in a designer derived from the ListControlDesigner class to ensure that only instances of a control class named SimpleRadioButtonList are used by the custom designer.

此代码示例是为类提供的更大示例的一部分 ListControlDesignerThis code example is part of a larger example provided for the ListControlDesigner class.

public override void Initialize(IComponent component)
{
    // Ensure that only a SimpleRadioButtonList can be 
    // created in this designer.
    Debug.Assert( 
        component is SimpleRadioButtonList, 
        "An invalid SimpleRadioButtonList control was initialized.");

    simpleRadioButtonList = (SimpleRadioButtonList)component;
    base.Initialize(component);
} // Initialize
Public Overrides Sub Initialize(ByVal component As IComponent)

    ' Ensure that only a SimpleRadioButtonList can be created 
    ' in this designer.
    Debug.Assert( _
        TypeOf component Is SimpleRadioButtonList, _
        "An invalid SimpleRadioButtonList control was initialized.")

    simpleRadioButtonList = CType(component, SimpleRadioButtonList)
    MyBase.Initialize(component)
End Sub

注解

当设计器宿主 Initialize 准备好使用设计器呈现从类派生的控件时,将调用方法 ListControlThe designer host calls the Initialize method when it is ready to use the designer to render the control that is derived from the ListControl class. Initialize方法及其基方法会配置属性并连接到设计器操作所需的事件。The Initialize method and its base methods configure properties and connect to events that are necessary for the operation of the designer.

component参数是派生自的控件, ListControl 它与此设计器关联或是该控件的副本。The component parameter is the control, derived from the ListControl, that is associated with this designer or is a copy of that control.

适用于

另请参阅