Control.OnCreateControl 方法

定义

引发 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 ()

注解

第一次创建控件时,将调用 OnCreateControl 方法。The 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.

适用于

另请参阅