tags:

views:

36

answers:

1

How can I get the Y position of the ContextMenuStrip?

+1  A: 

As far as I know, contextMenuStrips don't have a "location" field. A location is set once it's shown like so:

Dim thePoint As Point = (New System.Drawing.Point(someXValue, someYValue))
ContextMenuStrip1.Show(PictureBox1.PointToScreen(thePoint))

The previous code creates a point, and as the contextMenuStrip is being shown, it assigns the location right then. If you wanted to retrieve the location of that contextMenuStrip after show() as been called, you can cast the object and retrieve the location like so

 MessageBox.Show(DirectCast(ContextMenuStrip1, ToolStrip).Location.Y)
AndyPerfect