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,實作 IComponent 介面。
例外狀況
範例
下列程式碼範例示範如何覆寫 Initialize 繼承自 MenuDesigner 類別的 類別中的 方法。 覆寫的方法會變更在設計階段衍生自 Menu 類別的控制項行為。 如果相關聯的控制項不是 MyMenu
物件,此範例會 ArgumentException 擲回例外狀況。
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
備註
當視覺化設計工具準備好使用設計工具來轉譯 Menu 控制項時,會呼叫 Initialize 方法。 方法 Initialize 及其基底方法會設定屬性,並設定設計工具作業所需的事件。
參數 component
是 Menu 與此設計工具或該控制項複本相關聯的控制項。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應