Version

VisibleRows Property

Returns a reference to a VisibleRows collection of the Row objects that are currently displayed in a rowscrollregion. This property is read-only at run-time. This property is not available at design-time.
Syntax
'Declaration
 
Public ReadOnly Property VisibleRows As VisibleRowsCollection
public VisibleRowsCollection VisibleRows {get;}
Remarks

This property returns a reference to a VisibleRows collection that can be used to retrieve references to the Row objects that are currently displayed in a rowscrollregion. You can use this reference to access any of the returned collection's properties or methods, as well as the properties or methods of the objects within the collection.

As rows in the rowscrollregion are scrolled into and out of view, their corresponding Row objects are added to and removed from the VisibleRows collection returned by this property.

Rows that have their Hidden property set to True, and therefore are not displayed, are not included in the collection.

The Count property of the returned VisibleRows collection can be used to determine the number of rows currently displayed in the rowscrollregion.

NOTE: The visible rows collection will always contain an extra row scrolled out of view at the bottom. This is helpful in determining the next row that will come into view when the row scroll region is scrolled down by one row. See example section to find out the dimensions of visible rows and if they are actually visible on the screen.

Example
Following code shows how to find out if a row in the visible rows collection is actually visible and its dimensions. Visible rows collection will always contain an extra row that's scrolled out of view at the bottom. As a result the items contained in the visible rows collection do not truly reflect the visible states of the rows it contains.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Function IsRowVisible(ByVal row As Infragistics.Win.UltraWinGrid.UltraGridRow) As Boolean
        Dim rowElement As Infragistics.Win.UIElement = _
            Me.UltraGrid1.DisplayLayout.UIElement.GetDescendant( _
                    GetType(Infragistics.Win.UltraWinGrid.RowUIElement), row)

        If Not Nothing Is rowElement Then
            ' You can also check if the row is horizontally scrolled out view by
            ' checking to see if the row rectangle intersects the grid's rectangle.
            '
            If Not Rectangle.Intersect(Me.UltraGrid1.ClientRectangle, rowElement.Rect).IsEmpty Then
                Return True
            End If
        End If

        Return False
    End Function

    Private Function GetVisibleRowCount(ByVal visibleRows As Infragistics.Win.UltraWinGrid.VisibleRowsCollection) As Integer
        Dim visCount As Integer = 0

        Dim vr As Infragistics.Win.UltraWinGrid.VisibleRow

        For Each vr In visibleRows
            If Me.IsRowVisible(vr.Row) Then
                visCount += 1
            End If
        Next

        Return visCount
    End Function


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("" & Me.GetVisibleRowCount(UltraGrid1.DisplayLayout.RowScrollRegions(0).VisibleRows))
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private bool IsRowVisible( Infragistics.Win.UltraWinGrid.UltraGridRow row )
		{
			Infragistics.Win.UIElement rowElement =
				this.ultraGrid1.DisplayLayout.UIElement.GetDescendant( 
				typeof( Infragistics.Win.UltraWinGrid.RowUIElement ), row );

			if ( null != rowElement )
			{
				// You can also check if the row is horizontally scrolled out view by
				// checking to see if the row rectangle intersects the grid's rectangle.
				//
				if ( ! Rectangle.Intersect( this.ultraGrid1.ClientRectangle, rowElement.Rect ).IsEmpty )
					return true;
			}

			return false;
		}

		private int GetVisibleRowCount( Infragistics.Win.UltraWinGrid.VisibleRowsCollection visibleRows )
		{
			int visCount = 0;

			foreach ( Infragistics.Win.UltraWinGrid.VisibleRow vr in visibleRows )
			{
				if ( this.IsRowVisible( vr.Row ) )
					visCount++;
			}

			return visCount;
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show( "" + this.GetVisibleRowCount( ultraGrid1.DisplayLayout.RowScrollRegions[0].VisibleRows ) );
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also