Check for event in event queue

When a context menu item is clicked, the click event isn't handled immediately. Instead, the context menu is dismissed, subsequent statements (statements following the calling of the Show method of the menu) are executed, and only then the menuitem's click event is handled.

I need that, immedately after calling Show, before any other statement is executed, to determine if a certain menuitem was clicked.

I thought of checking whether the click event of the menuitem is in the event queue, but how to do that? Or maybe there is another solution?
Who is Participating?
AlexFMConnect With a Mentor Commented:
Application.DoEvents();    // here context menu item handler is called
// ... other code

In item handler you can set some variable which can show you that item was selected.

campinasAuthor Commented:
Thank you, appreciate your help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.