Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
505
Positioning ContextMenu Programmatically
posted

I implemented UltraGrid_MouseUp event handler, wanted to dynamically pop up contextmenu when the mouse being clicked on the grid.
But it did not work, it got a system overflow.   Can you point out why, and what is the right way to do?

private void ultraGrid1_MouseUp( object sender, MouseEventArgs e )
{
.........
    contextMenuStrip1.Items.Add( "Assigned", null, new System.EventHandler( this.Assigned_OnClick ) );
    // Add a menu item for the Unchecked state.
    contextMenuStrip1.Items.Add( "Unassigned", null, new System.EventHandler( this.Unasssigned_OnClick ) );

    contextMenuStrip1.Location = ultraGrid1.PointToScreen(e.Location);

    contextMenuStrip1.Show( contextMenuStrip1, e.X, e.Y );
..........
}

if I don't position it, the menu goes to left-top corner of the screen.


Also how the handler Assigned_OnClick() get to use the EventArgs "e" in its implementation?

protected void Assigned_OnClick( System.Object sender, System.EventArgs e )
{
    MessageBox.Show( "Assigned_OnClick: " + e.ToString() );
}

Parents
No Data
Reply
  • 505
    posted

    When I removed the setting of the Location, it worked.

    // contextMenuStrip1.Location = ultraGrid1.PointToScreen(e.Location)

    It will be appreciated If anyone can share how to utilize "System.EventArgs e" in the handler.

Children