MenuDesigner.Initialize(IComponent) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
准备设计器以查看、编辑和设计关联的控件。
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
实现接口的 Menu AIComponent。
例外
示例
下面的代码示例演示如何重写 Initialize 从 MenuDesigner 类继承的类中的方法。 重写的方法更改在设计时派生自类的 Menu 控件的行为。 如果关联的控件不是ArgumentException对象,该示例将MyMenu引发异常。
public override void Initialize(IComponent component)
{
// Ensure that only a MyMenu can be created in this designer.
if (!(component is MyMenu))
throw new ArgumentException(
"The component is not a MyMenu control.");
base.Initialize(component);
} // Initialize
Public Overrides Sub Initialize(ByVal component As IComponent)
' Ensure that only a MyMenu can be created in this designer.
If Not TypeOf component Is MyMenu Then
Throw New ArgumentException( _
"The component is not a MyMenu control.")
End If
MyBase.Initialize(component)
End Sub
注解
视觉对象设计器在准备好使用设计器呈现控件时调用 Initialize 该方法 Menu 。 该方法 Initialize 及其基方法配置属性并设置设计器操作所需的事件。
参数 component 是 Menu 与此设计器或该控件的副本关联的控件。