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
80
Select a row with a right clik mouse
posted

i need can select with a right click mouse in a ultragrid.

please help me.

Parents
No Data
Reply
  • 21795
    Offline posted

    Hello Alexander,

    One possible solution is to handle the MouseUp event. In this event you can check the UIElement where the mouse was when click was performed. Check if this UIElement is RowUIElement or if any of its ancestors is such element. If so get the Row of the RowUIElement and activate it. Here is how you can achieve this:

    private void UltraGrid1_MouseUp(object sender, MouseEventArgs e)
    {
        var grid = sender as UltraGrid;
        if(grid == null)
            return;

        //  If this is not Right mouse button return
        if(e.Button != MouseButtons.Right)
            return;

        //  Get the element under the mouse location
        var element = grid.DisplayLayout.UIElement.ElementFromPoint((e.Location));

        //  Check if the element is RowUIElement or if some of its ancestors
        //  is RowUIElement
        RowUIElement rowElement = null;
        if(element is RowUIElement)
            rowElement = element as RowUIElement;
        else
            rowElement = element.GetAncestor(typeof(RowUIElement)) as RowUIElement;

        //  If we have found a RowUIelement get its Row and activate it
        if(rowElement != null)
            rowElement.Row.Activate();
    }

    Please let me know if you have any additional questions.

Children