ControlDesigner.EnableDesignMode(Control, String) 方法

定義

啟用子控制項的設計階段功能。Enables design time functionality for a child control.

protected:
 bool EnableDesignMode(System::Windows::Forms::Control ^ child, System::String ^ name);
protected bool EnableDesignMode (System.Windows.Forms.Control child, string name);
member this.EnableDesignMode : System.Windows.Forms.Control * string -> bool
Protected Function EnableDesignMode (child As Control, name As String) As Boolean

參數

child
Control

將啟用設計模式的子控制項。The child control for which design mode will be enabled.

name
String

公開給使用者的 child 名稱。The name of child as exposed to the end user.

傳回

如果可以啟用設計階段的子控制項,則為 true,如果裝載基礎結構不支援它,則為 falsetrue if the child control could be enabled for design time; false if the hosting infrastructure does not support it.

例外狀況

childnamenullchild or name is null.

備註

child 所指定的子控制項是此控制項設計工具控制項的子系。The child control specified by child is a child of this control designer's control. 子系不會直接參與持續性,但如果它公開為主要控制項的屬性,它就會是。The child does not directly participate in persistence, but it will if it is exposed as a property of the main control. 請考慮像 SplitContainer的控制項:它有兩個面板,Panel1Panel2Consider a control like the SplitContainer: it has two panels, Panel1 and Panel2. 這些面板會透過 [唯讀 Panel1] 和 [SplitContainer] 控制項上 Panel2 屬性來公開。These panels are exposed through read only Panel1 and Panel2 properties on the SplitContainer control. SplitContainer 控制項的設計工具會針對每個面板呼叫 EnableDesignMode,讓其他元件可以放在它們上。The SplitContainer control's designer calls EnableDesignMode for each panel, which allows other components to be dropped on them. 但為了要儲存 Panel1Panel2 的內容,SplitContainer 控制項本身必須將面板公開為公用屬性。But, in order for the contents of Panel1 and Panel2 to be saved, the SplitContainer control itself must expose the panels as public properties.

控制項名稱在控制項設計工具中必須是唯一的,但對於其他控制項設計工具的子系而言,它們不一定是唯一的。Control names must be unique within a control designer, but they are not required to be unique with respect to the children of other control designers.

為了支援這項功能,裝載基礎結構必須透過網站公開 INestedContainer 類別做為服務。To support this feature, the hosting infrastructure must expose the INestedContainer class as a service through the site.

適用於