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.

如果控制項的 Visible 屬性為 falseCreateControl 就不會建立控制項控制碼。CreateControl 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.