FormClosedEventArgs.CloseReason 属性

来源:互联网 发布:windows网络编程教程 编辑:程序博客网 时间:2024/04/29 19:51
获取一个值,该值指示关闭窗体的原因。

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

语法

C#
C++
VB
public CloseReason CloseReason { get; }
J#
/** @property */public CloseReason get_CloseReason ()
JScript
public function get CloseReason () : CloseReason
XAML
不适用。

属性值

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
请参见

参考

FormClosedEventArgs 类 
FormClosedEventArgs 成员 
System.Windows.Forms 命名空间 
Form 
System.Windows.Forms.CloseReason 
原创粉丝点击