Control.CreateControl 方法


强制创建可见控件,包括创建句柄和任何可见子控件。Forces the creation of the visible control, including the creation of the handle and any visible child controls.

 void CreateControl();
public void CreateControl ();
member this.CreateControl : unit -> unit
Public Sub CreateControl ()


CreateControl方法强制为控件及其子控件创建句柄。The CreateControl method forces a handle to be created for the control and its child controls. 如果需要立即处理控件或其子级的句柄,则使用此方法;只调用控件的构造函数不会创建 HandleThis method is used when you need a handle immediately for manipulation of the control or its children; simply calling a control's constructor does not create the Handle.

CreateControl 如果控件的属性为,则不创建控件句柄 Visible falseCreateControl does not create a control handle if the control's Visible property is false. 可以调用 CreateHandle 方法或访问 Handle 属性来创建控件的句柄,而与控件的可见性无关,但在这种情况下,不会为控件的子级创建窗口句柄。You can either call the CreateHandle method or access the Handle property to create the control's handle regardless of the control's visibility, but in this case, no window handles are created for the control's children.