Using grid.ActiveRowScrollRegion.VisibleRows.Count, I can receive the count of visible rows in grid, including column headers and grid headers.
If grid is filled much, sometimes the last visible row is cropped - as show in this example with row #7.
The grid.ActiveRowScrollRegion.VisibleRows-Counter is 8 (cause of including column header).
But row #7 is not FULL visible. Is there a simple way to determine the really visible rows?
(or other possible solution: prevent grid from displaying "half lines")
-thanx
georges
Hello Georges,
Thank you for posting your request on the Infragistics WinForms Forum. The following code snippet demonstrates using the GetUIElement on each visible row and then comparing the UIElement.Rect with the UIElement.ClipRect to see if the row is clipped:
foreach (VisibleRow visibleRow in ultraGrid1.ActiveRowScrollRegion.VisibleRows){ if (visibleRow.Row.GetUIElement().Rect.Height > visibleRow.Row.GetUIElement().ClipRect.Height) { < add code here ......... > }}
Please let me know if this helps you help.Sincerely,Mike D.Developer Support EngineerInfragistics, Inc.
Hi Mike,
foreach (VisibleRow visibleRow in ultraGrid1.ActiveRowScrollRegion.VisibleRows) { if (visibleRow.Row.GetUIElement().Rect.Height > visibleRow.Row.GetUIElement().ClipRect.Height) { < add code here ......... > }}
foreach (VisibleRow visibleRow in ultraGrid1.ActiveRowScrollRegion.VisibleRows)
{ if (visibleRow.Row.GetUIElement().Rect.Height > visibleRow.Row.GetUIElement().ClipRect.Height) { < add code here ......... > }}
Hint: change if-condition from ">" to ">=" for matching rows - and all works fine.
I've added a null-reference-check also. So my final routine looks like this:
private int GetVisibleRows(UltraGridBase ultraGrid) { int RowCount = 0; if (ultraGrid == null) return RowCount; foreach (VisibleRow visibleRow in ultraGrid.ActiveRowScrollRegion.VisibleRows) { Infragistics.Win.UIElement element = visibleRow.Row.GetUIElement(); if (element == null) continue; if (element.Rect.Height >= element.ClipRect.Height) { RowCount++; } } return RowCount; }
Thanx for that fast reply and solution.
Sincerely,
- Georges