Hi, loving the ultraGrid sofar just a quick question...
What is the best way to get it to navigate around cells with the arrow keys like in excel (commiting any editing before moving away).
Is there a property somewhere or do I have to write some code in the keypress event?
NOTE: I have version 7.1
Thanks Mike, it works
Hi,
xdxie said:the left - right arrows should move the next- previous cells even they are in different columns.
The word "columns" gets a little fuzzy when dealing with CardView mode. I assume you want the arrow keys to move in an intuitive direction, so down would move to the next cell within a card and right would move to the next card, same cell.
Here's some code that works in both CardView and non-CardView mode.
private void ultraGrid1_KeyDown(object sender, KeyEventArgs e) { UltraGrid grid = (UltraGrid)sender; UltraGridCell activeCell = grid.ActiveCell; if (activeCell == null) return; Keys resolvedKeyCode = e.KeyCode; // When in CardView mode, change the direction by 90 degrees. if (activeCell.Band.CardView) { switch (resolvedKeyCode) { case Keys.Right: resolvedKeyCode = Keys.Down; break; case Keys.Left: resolvedKeyCode = Keys.Up; break; case Keys.Down: resolvedKeyCode = Keys.Right; break; case Keys.Up: resolvedKeyCode = Keys.Left; break; } } switch (resolvedKeyCode) { case Keys.Right: grid.PerformAction(UltraGridAction.NextCellByTab, false, false); grid.PerformAction(UltraGridAction.EnterEditMode, false, false); e.Handled = true; break; case Keys.Left: grid.PerformAction(UltraGridAction.PrevCellByTab, false, false); grid.PerformAction(UltraGridAction.EnterEditMode, false, false); e.Handled = true; break; case Keys.Down: UltraGridRow nextRow = activeCell.Row.GetSibling(SiblingRow.Next); if (nextRow != null) { nextRow.Cells[activeCell.Column].Activate(); grid.PerformAction(UltraGridAction.EnterEditMode, false, false); e.Handled = true; } break; case Keys.Up: UltraGridRow prevRow = activeCell.Row.GetSibling(SiblingRow.Previous); if (prevRow != null) { prevRow.Cells[activeCell.Column].Activate(); grid.PerformAction(UltraGridAction.EnterEditMode, false, false); e.Handled = true; } break; } }
Hi Mike,
I want to move between cells like Excel in card view mode with the arrows key. I'm using the same code in http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=1997
But in card view the result I got was: the left arrow is moving up and the right arrow is moving down, the behavior I expected: the left - right arrows should move the next- previous cells even they are in different columns.
Exactly what behavior do you want and which KB are you following?
I need the same behavior for a cardview mode grid. Following the KB the left and right arrows have the same behavior as the up and down arrows. I also tried switching the logic and the result was the same.