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
375
How to automatically enter edit mode when moving to a row.
posted

I am mapping the RETURN key to go to the next row, with this code:

// Force Return key to go to next row.

Infragistics.Win.UltraWinGrid.GridKeyActionMapping keyMapping =

new Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Keys.Return, UltraGridAction.NextRow, 0, 0, 0, 0);

this.ultraGrid_QuickBooksCustomers.KeyActionMappings.Add(keyMapping);

How do I make it enter edit mode when it goes to the next row?

 

  • 469350
    Verified Answer
    Offline posted

    You can add multiple KeyActionMappings for the same key and state and they will be executed in order.

    So you might be able to acheive what you want by adding a second mapping with exactly the same values, except for the Action, which would be EnterEditMode instead of NextRow. But it's probably more complicated than that, because NextRow probably leaves the grid in a state where there is an active row but no active cell. So you might have to use multiple actions.

    Personally, I find that using KeyActionMappings for this kind of thing is pretty tricky, and it's usually a lot easier to simply do this in code by handling the KeyDown or KeyPress event of the grid and calling the PerformAction method. But what you do depends on the behavior you want. Do you want to enter edit mode on the first cell in the row? Or the same cell that was active in the previous row? Do you always want to handle the return character this way - when a cell is in edit mode or when it's not in edit mode?

    There are too many unknowns here for me to give you a definitive solution. But here's a start:


            private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                if (e.KeyChar == (char)13)
                {
                    grid.PerformAction(UltraGridAction.ExitEditMode);
                    grid.PerformAction(UltraGridAction.NextRowByTab);
                    grid.ActiveRow.Cells[0].Activate();
                    grid.PerformAction(UltraGridAction.EnterEditMode);

                }
            }