Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

Changing ContextMenu

Hello,
I want to attach to a form a different ContextMenu each time, depending on the region in the form that was right clicked.
Does a form raise an event just before it displays a ContextMenu? (In Delphi the form raises the ContextPopup event.)
Libby
0
libbysharf
Asked:
libbysharf
  • 2
  • 2
1 Solution
 
PoeticAudioCommented:
The ContextMenu fires a Popup event which happens before the ContextMenu is actually displayed.
0
 
libbysharfAuthor Commented:
Thanks... But what if, as I said, I'm using several ContextMenus and switching betwwen them? Do I have to populate each one of them with the same event handler for popup? Wouldn't it be much less cumbersome if only the component they are attached to raise the event?
Does anyone know if there is such event that the component raise?
0
 
vo1dCommented:
you could use the forms mouseup event and check for right mousebutton and show the specific context menu.
private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                //show specific context menu
                specificContextMenut.Show(e.Location);
            }
        }
0
 
libbysharfAuthor Commented:
The problem is that the user can also use the keyboard to popup the menu....
Thanks anyway. vo1d, you get the points for the effort.
0
 
vo1dCommented:
yes he can, but for that, you could use the keyup event and make a call of the mouseup eventhandler with the correct mouseventargs.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now