Click to See Complete Forum and Search --> : Context menus


John Reynolds
October 19th, 2001, 11:47 AM
I have 2 DataGrids on frmMain. I want a different menu to popup when the user right clicks . . . depending on which DataGrid the mouse is over. Can you create multiple menus (completely different) at design time? Thanks for any input.

Cakkie
October 19th, 2001, 12:48 PM
Sure you can, just create them using the Menu editor, and show them using the PopupMenu method in the Mousedown event of the control. Some controls however have a default popup menu. I'm not sure about datagrids, but anyway, setting the control to disabled and back to enabled most of the time eliminates this behaviour.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

John Reynolds
October 19th, 2001, 02:47 PM
Tom, thanks for your quick reply. But, say you have used the Menu Editor & created a menu for frmForm1. How do you use the Menu Editor and create another menu (to be used as a popup)? When I click the Menu Editor, the 1st menu is there . . . and I can't see how to create another unless I create another form. (?)

Thanks in advance for your help.
John

John G Duffy
October 19th, 2001, 03:38 PM
A short example of two popup menus
Start a new project.
start the menu editor. Create menu items like so
Popup Menu 1 (mnuPopup1) visible = False
....> popup Sub 1 (mnuPopupSub1)
Popup Menu 2 (mnuPopup2) Visible = False
....> Popup Sub 2 (mnuPopupSub2

Add two command buttons. Here is the code for the command buttons

option Explicit

private Sub Command1_Click()
PopupMenu mnuPopup1
End Sub

private Sub Command2_Click()
PopupMenu mnuPopup2
End Sub




John G

John Reynolds
October 19th, 2001, 04:30 PM
Excellent! Things are so simple when you know the answers.

Thanks,
John

John Reynolds
October 19th, 2001, 04:35 PM
Tom, thanks. I finally see. I have been thinking that when you click on Menu Editor, you are only working with one menu . . .
Thanks,
John

Chris Eastwood
October 19th, 2001, 08:40 PM
<de-lurk>

You might want to checkout the excellent article on this site at :

http://www.codeguru.com/vb/articles/2043.shtml

- it shows how to create dynamic menus at run time using a class module - very nice compact concise code.

</de-lurk>


Chris Eastwood
VBCodeLibrary - http://www.vbcodelibrary.com