I have a mulplt band grid wher I'm trying to use the up/down arrow keys to go to the same column in the next row which may be a different band. I saw another post here and I am using _BeforePerformAction event. My grid rows look simlar to
Band0_Row1
Band1_Row1
Band1_Row2
Band2_Row1
Band0_Row2
Band1_Row3
Band2_ Row2
I can arrow down to Band2_Row1 using Action.NextRow, but then it stops and won't go to Band0_Row2. What do I need to do? Thanks.
Ron
Hi Ron,
Can you post the code you are using?
Here you go. The up arrow navigation seems to work just fine. One other thing: I can't get the active cell appearance to clear from the old row cell nor does it appear in the new row. The row is surrounded by a border when I just want the same cell different row to be activated.
private void ugGrid_BeforePerformAction(object sender, BeforeUltraGridPerformActionEventArgs e)
{
if (e.UltraGridAction == UltraGridAction.AboveCell || e.UltraGridAction == UltraGridAction.BelowCell)
UltraGridCell cell = this.ugGrid.ActiveCell;
int index = cell.Column.Index;
this.ugGrid.PerformAction(UltraGridAction.DeactivateCell);
e.Cancel = true;
switch (e.UltraGridAction)
case UltraGridAction.BelowCell:
if (cell.Row.HasChild())
this.ugGrid.PerformAction(UltraGridAction.NextRow);
}
else if (cell.Row.HasNextSibling(true))
this.ugGrid.PerformAction(UltraGridAction.NextRowByTab);
} this.ugGrid.ActiveCell = this.ugGrid.ActiveRow.Cells[index];
break;
case UltraGridAction.AboveCell:
if (cell.Row.HasPrevSibling(true))
this.ugGrid.PerformAction(UltraGridAction.PrevRowByTab);
else if (cell.Row.HasParent())
this.ugGrid.PerformAction(UltraGridAction.PrevRow);
this.ugGrid.ActiveCell = this.ugGrid.ActiveRow.Cells[index];
Hi,
Well, the reason it's not working is pretty clear. This code first checks to see if the row has a child, which in this case it does not. Then it checks to see if the row has any siblings and it does not. So it just bails out and does nothing.
I can't find any Action code that will go back up the chain to the parent rows. It looks like the only way to do this would be to do a recursive walk over the grid rows, which would be a bit tricky. But I think I figured it out. Try this:
private void ultraGrid1_BeforePerformAction(object sender, BeforeUltraGridPerformActionEventArgs e) { UltraGrid grid = (UltraGrid)sender; if (e.UltraGridAction == UltraGridAction.AboveCell || e.UltraGridAction == UltraGridAction.BelowCell) { UltraGridCell cell = grid.ActiveCell; int index = cell.Column.Index; grid.PerformAction(UltraGridAction.DeactivateCell); e.Cancel = true; UltraGridRow row = cell.Row; switch (e.UltraGridAction) { case UltraGridAction.BelowCell: if (row.HasChild()) { grid.PerformAction(UltraGridAction.NextRow); } else if (row.HasNextSibling(true)) { grid.PerformAction(UltraGridAction.NextRowByTab); } else { row = row.ParentRow; while(row != null) { if (row.HasNextSibling(true)) { row = row.GetSibling(SiblingRow.Next); row.Activate(); row.Selected = true; break; } else row = row.ParentRow; } } grid.ActiveCell = grid.ActiveRow.Cells[index]; break; case UltraGridAction.AboveCell: if (row.HasPrevSibling(true)) { grid.PerformAction(UltraGridAction.PrevRowByTab); } else if (row.HasParent()) { grid.PerformAction(UltraGridAction.PrevRow); } grid.ActiveCell = grid.ActiveRow.Cells[index]; break; } } }
Yes, that worked. Thanks