Component.CanRaiseEvents Component.CanRaiseEvents Component.CanRaiseEvents Component.CanRaiseEvents Property

定義

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

protected:
 virtual property bool CanRaiseEvents { bool get(); };
protected virtual bool CanRaiseEvents { get; }
member this.CanRaiseEvents : bool
Protected Overridable ReadOnly Property CanRaiseEvents As Boolean

屬性值

如果元件可以引發事件,則為 true,否則為 falsetrue if the component can raise events; otherwise, false. 預設為 trueThe default is true.

備註

這個屬性的預設實作永遠傳回trueThe default implementation of this property always returns true. 類別繼承自Component類別應該覆寫這個屬性,以讓您能夠停用的事件引發。Classes that inherit from the Component class should override this property to provide the ability to disable the raising of events. 例如,在Control類別,如果控制項正在裝載 ActiveX 控制項,為CanRaiseEvents屬性會傳回falseActiveX 控制項是否已凍結其事件。For example, in the Control class, if the control is being hosted as an ActiveX control, the CanRaiseEvents property returns false if the ActiveX control has its events frozen.

給繼承者的注意事項

如果您覆寫衍生類別中的,這個方法,並將它變更為傳回false,則EventHandlerList所傳回的集合Events屬性會傳回null事件。If you override this method in a deriving class and change it to return false, the EventHandlerList collection returned by the Events property returns null for an event. 事件可以仍新增或移除集合中,但集合Item[Object]屬性一律會傳回nullEvents can still be added and removed from the collection, but the collection's Item[Object] property will always return null.

適用於

另請參閱