Hi
I have used ultragrid and i have 50 rows in it and Vertical scroll bar in it also
So I want to know the number of rows which are actually displayed in view.
means rows actually in scroll region.
ultraGrid1.DisplayLayout.RowScrollRegions[0].VisibleRows.Count
I tried this but it gives extra rows which are not visible in view.
Any other suggestion??
There's no simple way to get the exact number. The VisibleRows collection usually contains one or two extra rows for efficiency when scrolling.
You could get a more accurate count using the UIElements:
private int GetVisibleRowCount(UltraGrid grid) { int count = 0; UIElement rowColRegionIntersectionUIElement = grid.DisplayLayout.UIElement.GetDescendant(typeof(RowColRegionIntersectionUIElement)); if (rowColRegionIntersectionUIElement != null) { foreach (UIElement rowElement in rowColRegionIntersectionUIElement.ChildElements) { if (rowElement is RowUIElementBase) { if (rowElement.Rect.IntersectsWith(rowColRegionIntersectionUIElement.Rect)) count++; } } } return count; }
This code is obviously not very efficient, since it has to loop, but it's probably not too bad, since there won't be that many rows visible, even in a grid that fills the screen.