i need can select with a right click mouse in a ultragrid.
please help me.
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();}
// 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.
you can Give me the same code in Vb.net?