473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

ToolStripMenuItem X Y Position

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.Ow ner, 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
Feb 21 '07 #1
2 12849
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.

:)
"Dave" <Ki************@community.nospamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.Ow ner, 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


Feb 22 '07 #2
Point p = wb.PointToClient(Control.MousePosition);
mnu.DropDown.OwnerItem = null;
mnu.DropDown.Show(p);
mnu.Invalidate();
Nov 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Maileen | last post by:
Hi, I've create an application which includes : - a toolstrip - a toolstripmenu - several toolstripmenuitem(s) so, now i have a menu like that : -File
2
by: genojoe | last post by:
I have a VB 2003 project that I have updated to 2005. I notice that MenuItem is being phased out and replaced by ToolStripMenuItem. I want to investigate the new capabilities of this new control...
0
by: genojoe | last post by:
I have a menu structure that formats that left aligns string1 and right aligns string2. To do this, I use the OwnerDraw, Popup, DrawItem and MeasureItem properties or events of the MenuItem class....
1
by: =?Utf-8?B?RjVGNUY1?= | last post by:
I have created a control by inheriting ToolStripMenuItem that has an image property called LargeImage. ------ public class EventSubMenuItem : ToolStripMenuItem { private Image _largeImage =...
1
by: Justin Cherniak | last post by:
I have a ToolStrip item which fires a function when clicked. The function will run to completion without any problems (if I set a breakpoint at the closing brace, no exception has been fired), but...
0
by: Dean Slindee | last post by:
I need to be able to separate toolstripmenuitems from toolstripseparators, both of which are children of a toolstripdropdropbutton. The last statement does not pass validation. Is there any way...
0
by: Paul E Collins | last post by:
I was using the MenuItem.Index property to get the position of a menu item. For example, the topmost item on the menu has an Index of 0, the next is 1, then 2, and so on. I've switched to the...
3
by: Martijn Mulder | last post by:
My application has a standard MenuStrip on top of the window and a ContextMenuStrip that pops up when the user clicks the right mouse button. I have defined a ToolStripMenuItem that I want to...
0
by: kyungdongkim | last post by:
Hi, I have a dynamically generated MenuStrip following this example: http://www.codeproject.com/useritems/Dynamic_MenuStrip.asp Basically the menu strip allows users to save and load reports. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.