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
610
Override CellClickAction at the Individual cell level
posted

I have a grid with read-only type behavior using AllowUpdate = false and CellClickAction = RowSelect at the DisplayLayout.Override level. Individual cells and the text within cannot be selected.

However, I want the user to be able to edit values of certain columns, one row at a time. I'd like to be able to handle some trigger ("Edit Row" on a context menu for example) then change the row into "edit mode" and maybe show an unbound column (or change the appearance on an empty unbound column) to show a save and cancel button.

But I'm having trouble getting certain cells on a particular row to be editable, and then to get the RowSelect CellClickAction turned off so I can actually click into them. Any tips?

Thanks!

  • 469350
    Offline posted

    Hi,

    There's no CellClickAction on the cell. But you could trap for the mouse click on a particular cell and then force the cell into edit mode in code.

    I would probably try this using the MouseDown event of the grid. You can use the x and y coordinates passed in to the event to detect which cell (if any) was clicked. There is some sample code on how to do that here:

    HOWTO:UltraWinGrid Mouse Position and Cell Identification

    Once you have the cell, you can make it the ActiveCell and then use the grid's PerformAction method to EnterEditMode.

    This probably won't work if you call this code directly from inside the MouseDown event, because you will enter the cell into edit mode and then the grid will select the row and thus the cell will leave edit mode. So you need to introduce a delay so that you code gets called after the grid finished processing the click. You can do this using a BeginInvoke to call a method which sets the ActiveCell and calls PerformAction.