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

4 posts, 0 answers
  1. Sakthivel
    Sakthivel avatar
    8 posts
    Member since:
    Feb 2008

    Posted 06 Mar 2008 Link to this post

    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
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 07 Mar 2008 Link to this post

    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
  3. Ken
    Ken avatar
    2 posts
    Member since:
    Apr 2009

    Posted 16 Aug 2011 Link to this post

    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
  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 19 Aug 2011 Link to this post

    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 >>

Back to Top