How to programmaticaly show Context Menu?

dranko

Member
Joined
Apr 16, 2006
Messages
16
Programming Experience
Beginner
How to programmaticaly show Context Menu (without mouse rightclicking).
 
One of the overloaded 'Show' methods, goes for both ContextMenu and ContextMenuStrip classes
 
JohnH said:
One of the overloaded 'Show' methods, goes for both ContextMenu and ContextMenuStrip classes

I have tryed that method, but I don't understand how it works. It has 6 overloads. First overload is for example ContextMenuStrip1.Show(control, position). If I want to show ContextMenuStrip1 when form loads (Form.Load event) what control to put in ContextMenuStrip1.Show(control, position). Can you give me an working example please.
 
It won't work on forms Load event because form isn't shown until after Load event handler is finished. Shown event works for this on startup.

Example to display ContextMenuStrip1 relative to Panel1:
VB.NET:
ContextMenuStrip1.Show(Panel1, New Point(10, 10))
Example to display ContextMenuStrip1 relative to Form:
VB.NET:
ContextMenuStrip1.Show(Me, New Point(10, 10))
 
JohnH said:
It won't work on forms Load event because form isn't shown until after Load event handler is finished. Shown event works for this on startup.

Example to display ContextMenuStrip1 relative to Panel1:
VB.NET:
ContextMenuStrip1.Show(Panel1, New Point(10, 10))
Example to display ContextMenuStrip1 relative to Form:
VB.NET:
ContextMenuStrip1.Show(Me, New Point(10, 10))
Thank you for quick answer, I appreciate it.
It works fine. :)
 
Back
Top