www.softwareriviera.com
Software Code
    New Code     Most Interesting     Don't Miss     Our picks  
C# - section

View Article
Get clicked position for Context Menu
See how you can get the cursor position when pressing the right mouse button.
The code below shows how you can get the cursor position when pressing the right mouse button on a control.


void contextMenu_Popup(object sender, EventArgs e)
{
ContextMenu menu = sender as ContextMenu;

if (menu != null)
{
// Get the cursor position in screen coordinates
Point screenPoint = Cursor.Position;

// Convert screen coordinates to a point relative to the control
// that was right clicked
Point clickedCoordinated = menu.SourceControl.PointToClient(screenPoint);
}
}


Date: 2012-6-9    Written by: Admin A
     See all articles in this section
Copyright © 2007-2009 SoftwareRiviera.com. All rights reserved.  | Terms of use | Disclaimer | Privacy Policy |