DocumentBase.BeforeClose 事件

定义

刚好在文档关闭之前发生。

public event System.ComponentModel.CancelEventHandler BeforeClose;

事件类型

CancelEventHandler

示例

下面的代码示例在文档关闭之前显示一个消息框。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentBeforeClose()
{
    this.BeforeClose += new System.ComponentModel.CancelEventHandler(ThisDocument_BeforeClose);
}

void ThisDocument_BeforeClose(object sender, System.ComponentModel.CancelEventArgs e)
{
    MessageBox.Show("The document is closing.");
}
Private Sub DocumentBeforeClose()
    AddHandler Me.BeforeClose, AddressOf ThisDocument_BeforeClose
End Sub

Private Sub ThisDocument_BeforeClose(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
    MessageBox.Show("The document is closing.")
End Sub

注解

该事件在文档关闭之前发生。 若要保持文档关闭,请将 Cancel 提供的对象的参数设置 CancelEventArgstrue

适用于