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
1104
Setting active row when right-clicking into grid
posted

Hi,

when I right-click a row of an ultragrid control which has a context menu, the ActiveRow property of the grid is not updated like you left-click on a row.

I saw some threads in this forum where people used workarounds like using the MouseDown or MouseUp events of the grid and set the ActiveRow or Selected property manually using UIElement etc.

In my opinion, these workarounds are too long-winded to implement them for every single grid you use, only to achieve this behaviour. You should not have to set the ActiveRow property manually every time in this case.

Is there a simpler way to achieve this, or is the handling of mouse events the only possibility?

It would be perfect if it would work like e.g. in Windows Explorer, where you right-click file without left-clicking it before, and the context menu opens for the selected file.

Thank you and best regards

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The problem is, the grid can't just assume that you want to set the ActiveRow, because unlike Windows Explorer, the grid supports the selection of multiple rows, and you need to be able to right-click on a selected row without changing the Active or Selected row.

    Having said that, it would not be difficult for us to add a property to automatically activate a row when you right-click on it. But there is no such property right now. I encourage you to Submit a feature request to Infragistics.

    In the mean time, you need to handle the MouseUp event and activate the row in code. To avoid repeating the same code on multiple grids, you could create a single static method that does this and call it from the MouseUp event of any grid you want. Or, you could derive your own control from the UltraGrid and override OnMouseUp.

Children
No Data