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. 这些面板通过只读 Panel1Panel2 SplitContainer 控件上的属性公开。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.

适用于