ToolStripMenuItem X Y Position

D

Dave

How do I show a context menu directly underneath a tool strip menu item?

I tried this, but a menu item is not a control so it will not build.
private void siteToolStripMenuItem_MouseDown(object sender, MouseEventArgs
e)

{


// contextMenu.Show((Control)siteToolStripMenuItem.Owner, e.X,
siteToolStripMenuItem.Height);

contextMenu.Show((Control)siteToolStripMenuItem, 0,
siteToolStripMenuItem.Height);

}

I also tried the "siteToolStripMenuItem.Owner" which does build and does
display my context menu, but I can't location the X position of the menu
item to properly have the context menu displayed underneath.

Anyone have any idea's?

Dave
 
D

Dave

Sorry, I prematurely posted, I found the solution. ToolStripMenuItem has a
Bounds member which has the X Y coordinates to use so you can properly place
the context menu.

:)
 
K

kamosion

Point p = wb.PointToClient(Control.MousePosition);
mnu.DropDown.OwnerItem = null;
mnu.DropDown.Show(p);
mnu.Invalidate();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top