Collapse event in C# ContextMenu does not work as expected.
Posted on 2008-11-05
I am trying to change the state of my application according to whether or not a ContextMenu is being displayed.
ContextMenu menu = new ContextMenu();
menu.Popup += new EventHandler( doSomething );
menu.Collapse += new EventHandler( doSomethingElse );
menu.Show(this, new Point(e.X, e.Y));
doSomething gets called as expected whenever a menu is shown but doSomethingElse is never called. I also tried to subclass ContextMenu and override the popup and collapse methods themselves. Again, the popup method worked but the collapse one was never called.
Are my expectations faulty or is it the code?