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
屬性值
如果元件可以引發事件,則為 true
,否則為 false
。true
if the component can raise events; otherwise, false
. 預設為 true
。The default is true
.
備註
這個屬性的預設實值一律true
會傳回。The 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.
給繼承者的注意事項
如果您在衍生類別中覆寫這個方法, 並將它false
變更為EventHandlerList null
傳回, 則Events屬性傳回的集合會針對事件傳回。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]屬性null
一律會傳回。Events can still be added and removed from the collection, but the collection's Item[Object] property will always return null
.