Blog Stats
  • Posts - 157
  • Articles - 0
  • Comments - 90
  • Trackbacks - 19

 

Intellisense doesn't show System.Windows.Forms.Form.Closed event (.NET 2.0)

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
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Gabriel Lozano-Morán