CancelEventHandler 委托

定义

表示处理可取消事件的方法。Represents the method that handles a cancelable event.

public delegate void CancelEventHandler(System::Object ^ sender, CancelEventArgs ^ e);
public delegate void CancelEventHandler(object sender, CancelEventArgs e);
type CancelEventHandler = delegate of obj * CancelEventArgs -> unit
Public Delegate Sub CancelEventHandler(sender As Object, e As CancelEventArgs)

参数

sender
Object

事件源。The source of the event.

e
CancelEventArgs

包含事件数据的 CancelEventArgsA CancelEventArgs that contains the event data.

继承
CancelEventHandler

示例

有关如何使用CancelEventHandler委托的示例, 请参阅CancelEventArgs类中的示例代码。For an example of how to use the CancelEventHandler delegate, please see the sample code in the CancelEventArgs class.

注解

创建 CancelEventHandler 委托时,需要标识将处理该事件的方法。When you create a CancelEventHandler delegate, you identify the method that will handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 只要事件发生, 就会调用事件处理程序方法, 除非删除委托。The event-handler method is called whenever the event occurs, unless you remove the delegate. 有关事件处理程序委托的详细信息, 请参阅处理和引发事件For more information about event-handler delegates, see Handling and Raising Events.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于

另请参阅