Hi,
now after hours of searching I can't find a way to scroll an activ row to the center of the grid.
With arrowkeys I navigate through all cells, when pressing ENTER I let the grid sorting the appropiate column and "yes I can" scroll "ScrollRowIntoView".
ultraGrid1.ActiveRowScrollRegion.ScrollRowIntoView(ultraGrid1.ActiveRow);
But I can't scroll to the center of the grid.
Are there any samples or methods to do this?
Thx Nobbi
Hi Mayank,
The grid does not select any row automatically. So if a row is getting selected, something in your code is selecting it.
The grid will synchronize the Active row with the Current position of the DotNet BindingManager, but Active and Selected are two different things. Also, the BindingManager typically activates the first row, not a row in the middle. So again, that may be something in your code. Or it may be that first row in the grid is activate, and then you are sorting the grid so that row ends up in the middle.
If you don't want the active row in the grid to appear highlighted, here's a link that should help:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=10117
Hello Guys,
I have a opposite situation. I have a form and it contains UltrawinGrid. When the grid is loaded with data. It is selecting a row in the somewhere middle on the grid by default. I dont want any row to be selected in the grid by default.
Let me know how can i do this?
Thanks,
Mayank
Hi Mike,
thank you very much.
That is exactly what I was looking for. I tested it and I couldn't find problems.
After sorting the Grids Column, I just called your Method ScrollRowToMiddle(ultraGrid1.ActiveRow).
Lot's of greetings from Germany.
Nobbi
Hi Nobbi,
There's no method in the grid to scroll a row into the exact middle. The only way to scroll to a specific position in the grid it so set the FirstRow property of the ActiveRowScrollRegion. So if you know what row you want to be in the middle and you know how many rows fit in the grid's display, you could find a row that is a few rows up from the one you want in the middle and make it the FirstRow. But how you do this will depend on lot on other factors and assumptions you can make in your application.
For example, if the row in question is the first row in the grid, then you cannot scroll it to the middle.
Here's some quick sample code I whipped up. It is by no means complete - it does not handle every case, but it should point you in the right direction.
private void ScrollRowToMiddle(UltraGridRow row) { UltraGrid grid = (UltraGrid)row.Band.Layout.Grid; UIElement gridElement = grid.DisplayLayout.UIElement; if (gridElement == null) return; UIElement rowColRegionIntersectionUIElement = gridElement.GetDescendant(typeof(RowColRegionIntersectionUIElement)); if (rowColRegionIntersectionUIElement == null) return; // Determine the total number of rows that can fit in the visible // area of the grid. We are assuming that the Rows are all the same height. int visibleRows = rowColRegionIntersectionUIElement.Rect.Height / row.Height; // Find the row that is half the visibleRows prior to the row we want. // UltraGridRow newFirstRow = row; int rowOffset = visibleRows / 2; for (int i = 0; i < rowOffset; i++) { if (newFirstRow.HasPrevSibling(false, true)) newFirstRow = newFirstRow.GetSibling(SiblingRow.Previous, false, true); } // Set the new FirstRow. grid.ActiveRowScrollRegion.FirstRow = newFirstRow; }