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
605
Right Click Action on Grid Row
posted

is there is away to handle the Right Click Action on Grid Row?

i just want to make the Row Selected When the user Right Click on it.

thanks.

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    One of several possible solutions is to handle MouseDown and programmatically select the row at the cursor position:

    void ultraGrid_MouseDown(object sender, MouseEventArgs e)
    {
        UltraGrid control = sender as UltraGrid;
        UIElement controlElement = control.DisplayLayout.UIElement;
        UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null;
        UltraGridRow rowAtPoint = elementAtPoint != null ? elementAtPoint.GetContext(typeof(UltraGridRow) ) as UltraGridRow : null;
        if ( rowAtPoint != null )
        {
            ISelectionManager selectionManager = control as ISelectionManager;
            if ( selectionManager.ActivateItem(rowAtPoint) == false )
            {
                bool clearExistingSelection = true;
                selectionManager.SelectItem( rowAtPoint, clearExistingSelection );
            }
        }
    }

    Note that you could also do this in response to MouseUp, MouseClick, etc.

Children
No Data