473,837 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get width of menu item

Hi,

I'm trying to right-align a context menu with its source control.

Here's what I have to LEFT align it:
'\\\
Dim pt As New Point(0, myButton.Height )
myContextMenu.S how(myButton, pt)
'///

It looks like I need the width of the context menu to get the correct point:
Dim pt as New Point(myButton. Width - myContextMenu.W idth, myButton.Height )

But there is no "Width" property for the context menu or its items. Does
anyone know how to do this without owner drawing the context menu?

Thank you
Nov 21 '05 #1
1 1781
Anon,

Try getting the rectangle associated with the control and use its Left and
Bottom properties.

For example:

private void MyControl_Mouse Up( object sender, MouseEventArgs e )
{
if ( e.Button == MouseButtons.Ri ght )
{
Point pt = new Point( this.ClientRect angle.Left,
this.ClientRect angle.Bottom );
this.contextMen u.MenuItems.Add ( this.helpItem );
this.contextMen u.MenuItems.Add ( this.scpiItem );
this.contextMen u.Show( this, pt );
this.contextMen u.MenuItems.Cle ar();
}
}

Hope that helps,
Dave

"anon" wrote:
Hi,

I'm trying to right-align a context menu with its source control.

Here's what I have to LEFT align it:
'\\\
Dim pt As New Point(0, myButton.Height )
myContextMenu.S how(myButton, pt)
'///

It looks like I need the width of the context menu to get the correct point:
Dim pt as New Point(myButton. Width - myContextMenu.W idth, myButton.Height )

But there is no "Width" property for the context menu or its items. Does
anyone know how to do this without owner drawing the context menu?

Thank you

Nov 21 '05 #2

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

Similar topics

1
5249
by: Michael Chernecki | last post by:
Hi I have a series of select menus on an online order form. I have limited space for the field width. Is is possible to have the menu width grow automaticallt to accomodate long item names. For instance, the field may be 1 inch width on the form, but when I click the menu it will expand to 2-3 inches wide to show a long item name, then return to normal size after making the selection. I don't care if the display of the select value gets...
12
1806
by: Tyrone Slothrop | last post by:
OK, I give up! I am trying to convert a JavaScript rollover button script to CSS. It is composed of background colors and font colors with the current page displaying the "over" state. I understand the basics and have accomplished a navigation bar that looks good and is functional. However, my client is very fussy about layout and requires that the nav bar be a specific width, with the buttons spreading across that width evenly, but...
5
4569
by: Chris Beall | last post by:
Objective: Using an HTML list, create a horizontal nav menu with these characteristics: - All menu items have the same width at all times. - When the window width is reduced, the menu items stack, rather than creating a horizontal scroll bar. - The menu cluster is always centered on the window. See http://pages.prodigy.net/chris_beall/Demo/centered%20horizontal%20list.html
1
6373
by: Simon Dean | last post by:
Hi, Im trying to learn CSS and putting a website in effect. Just getting used to DIV's and SPAN's and using the proper formatting of H1 H2 H3 etc to format HTML documents and using different stylesheets to control formatting. So far it's going pretty well, and Im just ripping up everything I knew about tables and starting with DIV's. Though I seem to be having a hell of a time working with padding and margins, then trying to realise...
4
4157
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get context help with that particular command. In VB6 this was easy, since each menu item had a "helpId" property. That doesn't seem to be the case in VB.NET. Am I wrong about that, or (alternatively) is there some other way to accomplish this? --
7
2247
by: Terry | last post by:
Hi again folks. I have a couple of issues now. I am not sure why I can't get my menu to overlap the content area. I tried using z-index. The effect I want occurs in Firefox but not IE. The other issue that I am having is that my drop down menu's width does not accomodate for the width of the content within the menu. (I am getting two lines for a menu entry when I just want one)
0
815
by: Mufasa | last post by:
I know how to set the width of the entire ASP:Menu. Is there anyway to set the width of a specific menu item? TIA - Jeff
2
5607
dlite922
by: dlite922 | last post by:
Before you baulk at yet another min-width problem, hear me out. I've been googling for a good hour now and experimenting but at no avail. I have a horizontal UL/LI menu and I want the li width to be at least a certain amount (say 100px) but also extend if the text is longer than that. Observe: that being said, I don't know how to implement the various solutions (CSS only, I do not want a JS solution) such as this one:
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10621
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7806
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6998
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5668
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.