Home Forums WinForms controls Xceed Grid for WinForms Visible rows in .net Xceed Grid for .Net Reply To: Visible rows in .net Xceed Grid for .Net

Xceed Support
Member
Post count: 5658

Hi Kunal,

I have created a method that returns the total number of rows that is available on screen. The GetNumberOfRowsInGrid will return the total number of rows available on screen. In the first part of my code, you can place the DataRows inside a collection.

C#

—————–

int FirstVisibleRowIndex = gridControl1.DataRows.IndexOf(this.gridControl1.FirstVisibleRow as Xceed.Grid.DataRow);
BindingList<Xceed.Grid.DataRow> VisibleRows = new BindingList<Xceed.Grid.DataRow>();
for (int i = 0; i < GetNumberOfRowsInGrid(); i++)
{
     VisibleRows.Add(this.gridControl1.DataRows[FirstVisibleRowIndex]);
     FirstVisibleRowIndex++;
}

private int GetNumberOfRowsInGrid()
{
     int RowHeight = this.gridControl1.DataRowTemplate.Height;
     int RectangleHeight = (this.gridControl1.DisplayRectangle.Height – (this.groupByRow1.Height + this.columnManagerRow1.Height));

     return (RectangleHeight / RowHeight);
}

—————–

I hope this helps 🙂

Imported from legacy forums. Posted by Marc [Xceed] (had 208 views)