visible area in gridview

7 posts, 0 answers
  1. yair
    yair avatar
    4 posts
    Member since:
    Feb 2010

    Posted 29 Jan 2012 Link to this post

    Hello..
    I want to know how many rows there are in the visible area in gridview..
    how can I do that?

    this is for controlling load of rows.. to get better performance..
    I want to load 30 rows each scrolling..
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 31 Jan 2012 Link to this post

    Hello Yair,

    You can get the rows that are visible by accessing the VisualRows property of GridTableElement:

    public IEnumerable<GridViewDataRowInfo> GetVisibleDataRows()
    {
        foreach (GridRowElement rowElement in this.myRadGridView1.TableElement.VisualRows)
        {
            if (rowElement.RowInfo is GridViewDataRowInfo)
            {
                yield return rowElement.RowInfo as GridViewDataRowInfo;
            }
        }
    }

    I hope this helps.

    Regards,
    Svett
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  3. yair
    yair avatar
    4 posts
    Member since:
    Feb 2010

    Posted 31 Jan 2012 Link to this post

    thanks Svett

    i'm using vb.net.
    I tried to convert the code to vb.net but i couldn't..
    can you write it in vb.net?
  4. Svett
    Admin
    Svett avatar
    728 posts

    Posted 02 Feb 2012 Link to this post

    Hi Yair,

    Here is the VB.NET version of the code snippet that I have sent you previously:

    Public Function GetVisibleDataRows() As IEnumerable(Of GridViewDataRowInfo)
        For Each rowElement As GridRowElement In Me.myRadGridView1.TableElement.VisualRows
            If TypeOf rowElement.RowInfo Is GridViewDataRowInfo Then
                yield Return TryCast(rowElement.RowInfo, GridViewDataRowInfo)
            End If
        Next
    End Function
    All the best,
    Svett
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  5. yair
    yair avatar
    4 posts
    Member since:
    Feb 2010

    Posted 02 Feb 2012 Link to this post

    it doesn't good.. I converted the c# code by Telerik converter tool too.. it doesn't work well..
    the converter dosn't know how to convert the code "yield"
  6. Svett
    Admin
    Svett avatar
    728 posts

    Posted 06 Feb 2012 Link to this post

    Hi Yair,

    Here is a valid VB.NET version of my code snippet:

    Public Function GetVisibleDataRows() As List(Of GridViewDataRowInfo)
        Dim result As New List(Of GridViewDataRowInfo)()
     
        For Each rowElement As GridRowElement In Me.myRadGridView1.TableElement.VisualRows
            If TypeOf rowElement.RowInfo Is GridViewDataRowInfo Then
                result.Add(TryCast(rowElement.RowInfo, GridViewDataRowInfo))
            End If
        Next
     
        Return result
    End Function

    I hope this helps.

    Regards,
    Svett
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  7. yair
    yair avatar
    4 posts
    Member since:
    Feb 2010

    Posted 07 Feb 2012 Link to this post

    thanks Svett!!! it's perfect! :-) 
Back to Top