PanelContainerDesigner.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
A Panel,實現了一個 IComponent。
例外狀況
範例
以下程式碼範例說明如何覆寫 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控制項時呼叫該Panel方法。 這些 Initialize 方法及其基礎方法會配置屬性並設定設計者操作所需的事件。
參數 component 是 Panel 與此設計器相關的控制項,或是控制項的 Panel 副本。