Context Menu won't go away.

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

On 2 of the 3 context menu selections, I show a new form, and the context
menu disappears. But one of the selections just causes the parent form to
refresh itself and the menu stays active. How do I hide it programmatically?
 
Hello

Alex said:
On 2 of the 3 context menu selections, I show a new form,
and the context menu disappears. But one of the selections
just causes the parent form to refresh itself and the menu
stays active. How do I hide it programmatically?

Do you want to hide the menu? Please post some code!
 
Hello



Do you want to hide the menu? Please post some code!

On right-mouse button click, I show the context menu

Event_handler(object sender, ...)
{
Control ctrl = (Control)sender;
sender.ContextMenu.Show();

}

The context menu appears, the selection works, but the menu stays visible
after the selection, how to make it go away?
 
Alex,
Is it that the menu is not going away, or that the underlying form is not be
repainted?

In your event handler you could use Control.Invalidate or Control.Refresh to
cause the control to be repainted.

Hope this helps
Jay

 
Try ctrl.ContextMenu = null; prior to calling any other code.

Once the menu is shown, it should close after the next mouse down. This is
not controllable as the menu has aquired the mouse and no other events will
fire until this menu closes. It is a modal dialog.

HTH,
Eric Cadwell
http://www.origincontrols.com


 
Back
Top