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