Al Bundy Al Bundy - 1 month ago 14
C# Question

How can I distinguish if a menu is opened or closed in the ToolStripMenuItem EventHandler

Adding an event handler to a

ToolStripMenuItem
like this:

foo = new ToolStripMenuItem( title, image, EVENT_HANDLER );


then the
EVENT_HANDLER
is called when the menu has been clicked


  1. to open, or

  2. to close the menu item.



My question:

How can I distinguish in the
EVENT_HANDLER
if the event was triggered because the menu is going to be closed?

Update:

I am not talking about
ToolStripDropDown
.

Answer

You probably won't be able to get that information from the Clicked event.

A work-around would be to use a variable for tracking the status and using the menu's DropDownOpening and DropDownClosed events to keep track of the open status of the menu.