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

FirstDisplayedScrollingRowIndex ?

7 Answers 698 Views
GridView
This is a migrated thread and some comments may be shown as answers.
guillaumeGL
Top achievements
Rank 2
guillaumeGL asked on 26 Nov 2009, 03:58 PM
Hello

I can't find any reference to FirstDisplayedScrollingRowIndex for the radgridview as it exists in datagridview. Did i missed it, or is there another way to obtain this property in a radgridview ?

Best Regards,
Guillaume.
Adiial

7 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 27 Nov 2009, 09:24 AM
Hello Guillaume,

Yes, there is no such method in RadGridView. However, you can use the following code to get the index:

public int GetFirstDisplayedScrollingRowIndex(RadGridView grid)
{
    foreach (GridRowElement row in grid.GridElement.VisualRows)
    {
        GridViewDataRowInfo dataRowInfo = row.RowInfo as GridViewDataRowInfo;
        if (dataRowInfo != null)
        {
            return grid.Rows.IndexOf(dataRowInfo);
        }
    }
    return -1;
}

I hope this helps.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
guillaumeGL
Top achievements
Rank 2
answered on 27 Nov 2009, 10:50 AM
It do the trick, thank you !

Guillaume.
Adiial
0
Rawad
Top achievements
Rank 2
answered on 22 Aug 2016, 12:15 PM

Dear  

the property  FirstDisplayedScrollingRowIndex is not shown in telerik,  how to set a row in the datagrid to be displayed at the top of the grid, not using the pinposition property.

The problem is that when the user is adding a lot of rows (the adding rows is on the bottom), the user must use the scroll bar of a grid to go down , and it's a little bit difficult.

using the usual gridview : 

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index;

how to use it in telerik ?

0
Rawad
Top achievements
Rank 2
answered on 22 Aug 2016, 12:16 PM

Dear  

the property  FirstDisplayedScrollingRowIndex is not shown in telerik,  how to set a row in the datagrid to be displayed at the top of the grid, not using the pinposition property.

The problem is that when the user is adding a lot of rows (the adding rows is on the bottom), the user must use the scroll bar of a grid to go down , and it's a little bit difficult.

using the usual gridview : 

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index;

how to use it in telerik ?

0
Hristo
Telerik team
answered on 22 Aug 2016, 02:50 PM
Hi ,

Thank you for writing.

You can easily scroll to the last added row by calling its EnsureVisible. A suitable place is the handler of the UserAddedRow event: 
private void radGridView1_UserAddedRow(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e)
{
    e.Row.EnsureVisible();
}

If you want the row to be added an index 0, depending on whether you are data bound or not you have two options:
  1. In unbound mode you can simply reorder the Rows collection: 
    //Unbound mode
    private void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
    {
        this.radGridView1.Rows.Move(e.Row.Index, 0);
    }
  2. If the grid is data bound you would need to reorder the items within your data source, if it allows it. The example below handles a scenario when you have a bound DataTable: 
    //Bound mode
    private void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
    {
        DataTable dtable = (DataTable)this.radGridView1.DataSource;
        DataRow dr = dtable.Rows[dtable.Rows.Count - 1];
        DataRow newRow = dtable.NewRow();
        newRow.ItemArray = dr.ItemArray;
      
        dtable.Rows.Remove(dr);
        dtable.Rows.InsertAt(newRow, 0);
    }
I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Rawad
Top achievements
Rank 2
answered on 24 Aug 2016, 12:19 PM

Dear

 

Kindly check the attached photos.

Photo1.png  shows that there's no place and free enough space to add new row. The user must go to scroll with the mouse each time to add 1 row.

there's a way to add big empty white space (maybe, to resize the heigh of the grid . . . )  to looks as the photo 2.

it's easier for the user to add new rows

0
Hristo
Telerik team
answered on 25 Aug 2016, 12:09 PM
Hi ,

Thank you for writing back.

You can achieve the desired result by pinning the new row to the bottom. Please see below: 
this.radGridView1.MasterView.TableAddNewRow.PinPosition = Telerik.WinControls.UI.PinnedRowPosition.Bottom;

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
guillaumeGL
Top achievements
Rank 2
Answers by
Jack
Telerik team
guillaumeGL
Top achievements
Rank 2
Rawad
Top achievements
Rank 2
Hristo
Telerik team
Share this question
or