473,387 Members | 1,388 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,387 software developers and data experts.

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.Show(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.Width, 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 1747
Anon,

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

For example:

private void MyControl_MouseUp( object sender, MouseEventArgs e )
{
if ( e.Button == MouseButtons.Right )
{
Point pt = new Point( this.ClientRectangle.Left,
this.ClientRectangle.Bottom );
this.contextMenu.MenuItems.Add( this.helpItem );
this.contextMenu.MenuItems.Add( this.scpiItem );
this.contextMenu.Show( this, pt );
this.contextMenu.MenuItems.Clear();
}
}

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.Show(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.Width, 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
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...
12
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...
5
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...
1
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...
4
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...
7
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. ...
0
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.