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
2306
Make Keys.Enter work like Keys.Tab does not work on TemplateAddRow
posted

I'm using this code to try to solve this problem but it does not work.

UltraGrid Grid = ultraGrid1;
            GridKeyActionMapping newKam;

            // remove the KeyActionMappings for Keys.Enter
            for (int i = 0 ; i< Grid.KeyActionMappings.Count; i++)
            {
                Infragistics.Win.UltraWinGrid.GridKeyActionMapping ogKam = Grid.KeyActionMappings[i];

                if (ogKam.KeyCode == Keys.Enter)
                {
                    Grid.KeyActionMappings.Remove(ogKam);
                }
            }


            foreach (Infragistics.Win.UltraWinGrid.GridKeyActionMapping ogKam in Grid.KeyActionMappings)
                if (ogKam.KeyCode == Keys.Tab)
                {
                    newKam = new Infragistics.Win.UltraWinGrid.GridKeyActionMapping(Keys.Enter, ogKam.ActionCode, ogKam.StateDisallowed, ogKam.StateRequired, ogKam.SpecialKeysDisallowed, ogKam.SpecialKeysRequired);
                    Grid.KeyActionMappings.Add(newKam);
                }

 

How can i fix that?

i'm using TemplateOnBottom AddRow. The problem is that if i'm editing a cell on newrow and then press enter it creates a newrow instead of jumping to the next cell..

as Attachment a sample project

UltraGrid Test KeyActionMapping.zip
  • 2306
    posted

    There is a mapping that cause this mess. Removing it, now works.

    On the first part of my code, instead of  if (ogKam.KeyCode == Keys.Enter) i have used

    if (ogKam.KeyCode == Keys.Enter && ogKam.ActionCode == UltraGridAction.CommitRow && (ogKam.StateRequired == (UltraGridState.AddRow | UltraGridState.RowDirty)))

    is there any problem removing this mapping?