Context Menu won't go away.

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?
 
H

Herfried K. Wagner [MVP]

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!
 
A

Alex

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?
 
J

Jay B. Harlow [MVP - Outlook]

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

 
E

Eric Cadwell

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


 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top