Component.CanRaiseEvents 屬性

定義

取得值,指出元件是否能引發事件。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

屬性值

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 false 如果 activex 控制項的事件已凍結,則屬性會傳回。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.

給繼承者的注意事項

如果您在衍生類別中覆寫這個方法,並將其變更為傳回 falseEventHandlerList 則屬性傳回的集合會 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.

適用於

另請參閱