Geeks With Blogs
Gabriel Lozano-Morán blog

Why doesn't the IntelliSense show the Closed event of a form in WinForms 2.0 application?

You don't see this member because it is decorated with the EditorBrowsable attribute passing the enum value EditorBrowsableState.Never to its constructor. The IntelliSense engine in Visual Studio doesn't show members that are marked as Never. This doesn't mean that you can't use this event because you can.

Why did the designers decide to mark the Closed event as being never browsable?

The answer to this question is that the events Closed and Closing too by the way are obsolete and that the events FormClosed and FormClosing should be used instead.

Why are the events Closed and Closing obsolete?

I don't know exactly why but using Reflector I could easily determine that they have also added two new delegates and two new classes for event data:

The only addition to the new classes for the event data is a CloseReason property of the enum type System.Windows.Forms.CloseReason. The enum type shows some interesting values like ApplicationExitCall, WindowsShutDown and TaskManagerClosing.

When you use the Closed event you need to know that when you call Application.Exit() the events Closed and Closing will not be raised. The events FormClosing and FormClosed however will be raised and now you have the opportunity to have different execution paths depending on the reason why these events were raised.


Cross-posted from The .NET Aficionado Posted on Tuesday, November 21, 2006 2:48 PM .NET Framework | Back to top


Comments on this post: Intellisense doesn't show System.Windows.Forms.Form.Closed event (.NET 2.0)

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Gabriel Lozano-Morán | Powered by: GeeksWithBlogs.net