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
1640
Detecting tab key on the last cell in a row
posted

I have an event defined to automaticlly add a new row when the user tabs out of the last cell.  The problem is that this event fires wwhen the user enters the last cell rather than after leaving it with the tab key.  My current logic is below - how should it be fixed?

grid.AfterPerformAction += new AfterUltraGridPerformActionEventHandler(OnGridPerformAction);

public static void OnGridPerformAction(object sender, AfterUltraGridPerformActionEventArgs e)

{

    if (sender != null && sender is UltraGrid)

       {

        UltraGrid grid = (UltraGrid)sender;

        if (e.UltraGridAction == UltraGridAction.NextCellByTab)

              {

            if ((grid.CurrentState & UltraGridState.CellLast) == UltraGridState.CellLast)

                         AddBlankGridRow(grid);

               }
        }

}

Parents
No Data
Reply
  • 48586
    posted

    Hello,

     

    AfterPerformAction even occurs after the action was executed, which meant that using your code in this even adds new row if the last cell of the last row was reached. And this cause your issue. So you should move your code in BeforePerformAction even, please see attached sample and let me know if this is what you are looking for.

     

    Please let me know if you have any further questions.

    135660.zip
Children