This is a migrated thread and some comments may be shown as answers.

visible area in gridview

6 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yair
Top achievements
Rank 1
yair asked on 29 Jan 2012, 04:34 PM
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..

6 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 31 Jan 2012, 03:03 PM
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).

0
yair
Top achievements
Rank 1
answered on 31 Jan 2012, 04:00 PM
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?
0
Svett
Telerik team
answered on 02 Feb 2012, 11:41 AM
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).

0
yair
Top achievements
Rank 1
answered on 02 Feb 2012, 11:20 PM
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"
0
Svett
Telerik team
answered on 06 Feb 2012, 12:54 PM
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).

0
yair
Top achievements
Rank 1
answered on 07 Feb 2012, 07:35 PM
thanks Svett!!! it's perfect! :-) 
Tags
GridView
Asked by
yair
Top achievements
Rank 1
Answers by
Svett
Telerik team
yair
Top achievements
Rank 1
Share this question
or