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 控件承载, 则当 activex 控件的事件冻结时false , 属性将CanRaiseEvents返回。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.

适用于

另请参阅