I want to cancel the adding of a new row when the user press Enter in the last cell of the "add row" and make that row the active row. This is because when pressing Enter key in the last cell the grid adds a new "add row", I don't want that, but it is ok to move to the first cell in the next row (not the add row) when pressing Enter in the last cell of a row. Got it? :) Thanks
Hi,
I'm not sure I understand. The grid does not add any new rows automatically when you press Enter, unless you are already in an AddNew Row and your AllowAddNew property is set to one of he options for TabRepeat or maybe a Fixed AddRow.
What is your AllowAddNew setting?
I have
ultraGrid1.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.
AllowAddNew.TemplateOnBottom
Look this:
As soon as you make any changes to anything in the TemplateAddRow, that row becomes an AddRow and a new TemplateAddRow is created.
Pressing Enter from any cell within a fix AddRow commits the changes to that row. Are you saying that this only happens when you are in the last column? I don't see any reason why that should be the case.
Either way, if you want to disable the Enter key from committing the new row, I think you would have to modify the grid's KeyActionMappings collection and remove the mapping for the Enter key with an action of CommitRow.
The code would look something like this:
for (int i = this.ultraGrid1.KeyActionMappings.Count - 1; i >= 0; i--) { KeyActionMappingBase kam = this.ultraGrid1.KeyActionMappings[i]; if (kam.KeyCode == Keys.Enter) { UltraGridAction action = (UltraGridAction)kam.ActionCode; if (action == UltraGridAction.CommitRow) { this.ultraGrid1.KeyActionMappings.Remove(kam); } } }
You would do this up-front, so maybe in the Form_Load event or in your form's constructor.