FormClosedEventArgs.CloseReason 属性

获取一个值,该值指示关闭窗体的原因。

命名空间: System.Windows.Forms
程序集: System.Windows.Forms(在 system.windows.forms.dll 中)

public CloseReason CloseReason { get; }
J#
/** @property */
public CloseReason get_CloseReason ()

public function get CloseReason () : CloseReason

不适用。

属性值
System.Windows.Forms.CloseReason 枚举值之一。

Form 关闭的原因很多,包括用户启动和编程的原因。CloseReason 属性指示关闭的原因。

下面的代码示例演示此成员的用法。在此例中,事件处理程序报告 Form.FormClosed 事件的发生。此报告有助于您了解事件的发生时间,并帮助您进行调试。要对多个事件或经常发生的事件进行报告,应考虑将 System.Windows.Forms.MessageBox.Show 替换为 System.Console.WriteLine,或者将该消息追加到一个多行 TextBox 的末尾。

要运行此代码示例,请将它粘贴到包含名为 Form1 的 Form 类型实例的项目中。然后,确保该事件处理程序与 Form.FormClosed 事件相关联。

C#
VB
private void Form1_FormClosed(Object sender, FormClosedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "FormClosed Event" );
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

.NET Framework
受以下版本支持:3.0、2.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值