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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17650 |

    How Could i find the rows which are visible ?

    for example , i added 100 rows, and at a time there are 40 -45 rows are visible.

    by programming, how could i get the visible row numbers /count.

    If i scroll down/ up in that case it should very , i could find the first visible row but number of visible rows / last visible row is not avaiable.

    Could you help me out.

    Imported from legacy forums. Posted by Kunal (had 2029 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Marc for reply,

    Is this going to support if few grids are having data with multiple lines / different height ?

    i.e. the data in first 3 rows are “abcd” —  height = 25

    4th row is having some data like “abcd /r/n efgh” —height =35.

    then after few rows say for example 

    10th row is having some data like “abcd /r/n efgh /r/n xyxs” —height =50.

     or this will work with common height only ?

     

     

     

    Imported from legacy forums. Posted by Kunal (had 293 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Kunal,

    If there are different heights, then this method will not work. Another way of doing it would be to get the sorted DataRows (rows as they are sorted to the user on the screen) and check their heights individually and check to see if the accumulated height is less than the height of the rectangle. If it is, continue the loop. If it is not, then you can stop.

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.