Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Get width of menu item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
- 30 Sep 2004 16:25 GMT
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
Dave Leach - 01 Oct 2004 20:45 GMT
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

> Hi,
>
[quoted text clipped - 13 lines]
>
> Thank you

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.