Control.OnCreateControl Control.OnCreateControl Control.OnCreateControl Control.OnCreateControl Method

定義

引發 CreateControl() 方法。Raises the CreateControl() method.

protected:
 virtual void OnCreateControl();
protected virtual void OnCreateControl ();
abstract member OnCreateControl : unit -> unit
override this.OnCreateControl : unit -> unit
Protected Overridable Sub OnCreateControl ()

備註

第一次建立控制項時,會呼叫方法。OnCreateControlThe OnCreateControl method is called when the control is first created.

OnCreateControl 方法也允許衍生類別處理事件,而不用附加委派。The OnCreateControl method also allows derived classes to handle the event without attaching a delegate. 這是在衍生類別中處理事件的慣用技巧。This is the preferred technique for handling the event in a derived class.

給繼承者的注意事項

當在衍生類別中覆寫 OnCreateControl() 時,請確定呼叫基底類別的 OnCreateControl() 方法,使已註冊的委派能接收到事件。When overriding OnCreateControl() in a derived class, be sure to call the base class's OnCreateControl() method so that registered delegates receive the event.

適用於

另請參閱