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;否则为 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 属性在 ActiveX 控件事件冻结的情况下返回 falseFor 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,则 Events 属性返回的 EventHandlerList 集合将为事件返回 nullIf 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.

适用于

另请参阅