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

How to get a top row index when the Gridview in scrollbar

3 Answers 612 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sakthivel
Top achievements
Rank 1
Sakthivel asked on 06 Mar 2008, 12:37 PM
I am using Radgridview with scrollbar.I want to get a top row index while after scrolling the gridview.

Another thing i want to get a particular cell position that is LocationX and LocationY from Radgridview.

Regards,
Sakthy

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 07 Mar 2008, 11:47 AM
Hello Sakthivel,

Thank you for contacting us.

You can get the top visible row index by accessing the vertical scroll position in grid. Refer to the code snippet below:

GridVScrollBar vscrollBar = (GridVScrollBar)((GridTableElement)this.radGridView1.GridElement).Children[3]; 
int vindex = vscrollBar.Value; 
 

You can get the cell location by using the RowIndex and ColumnIndex properties of the GridCellElement. If you need the cell coordinates, use the ControlBoundingRectangle property.

Do not hesitate to write us, if you need further assistance.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ken
Top achievements
Rank 1
answered on 16 Aug 2011, 04:26 PM
Has the way to do this changed for later releases?  I don't seem to have GridVScrollBar defined - I'm on 2011 Q2 release.
Thanks
Ken
0
Jack
Telerik team
answered on 19 Aug 2011, 08:27 AM
Hi Ken,

Yes, we have changed a lot since 2008. Now RadGridView scrolls smoothly, not row by row. That is why this approach will not work anymore. You can do the job by using the Index property of GridViewRowInfo:

public int GetFirstVisibleRowIndex(RadGridView grid)
{
    foreach (GridRowElement row in this.radGridView1.TableElement.VisualRows)
    {
        if (row.RowInfo is GridViewDataRowInfo || row.RowInfo is GridViewGroupRowInfo)
        {
            return row.RowInfo.Index;
        }
    }
    return -1;
}

If you have further questions, I will be glad to help.
 
Best wishes,
Jack
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Erik
Top achievements
Rank 1
commented on 14 Jun 2022, 10:05 AM

Has this changed much of late? 
Dess | Tech Support Engineer, Principal
Telerik team
commented on 14 Jun 2022, 10:07 AM

Hi, Erik,

The above approach is still valid for returning the row index of the first visible row in RadGridView.

Tags
GridView
Asked by
Sakthivel
Top achievements
Rank 1
Answers by
Jack
Telerik team
Ken
Top achievements
Rank 1
Share this question
or