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
1528
Enter key moves focus to next row; first editable cell.
posted

How can I most efficiently set up a grid so that pressing enter will move focus the next row, first editable cell?

Parents
  • 69832
    Suggested Answer
    Offline posted

    Here is a code sample that demonstrates how to add a custom key-action mapping, and how to use the PerformAction method to do what you described here. Note that this is not necessarily a robust solution to your specific problem, but rather demonstrates some of the approaches you can take.

    //  Add a mapping that activates the next row
    this.ultraGrid.KeyActionMappings.Add(
        new GridKeyActionMapping(
            Keys.Enter,
            UltraGridAction.NextRow,
            0,
            UltraGridState.Row,
            SpecialKeys.All,
            0) );

    //  Handle AfterPerformAction, and enter edit mode on the first cell
    //  after the 'NextRow' action is performed.
    AfterUltraGridPerformActionEventHandler handler =
    delegate( object sender, AfterUltraGridPerformActionEventArgs args )
    {
        if ( args.UltraGridAction == UltraGridAction.NextRow )
        {
            this.ultraGrid.ActiveRow.Cells[0].Activate();
            this.ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
        }
    };

    this.ultraGrid.AfterPerformAction += handler;

Reply Children