FirstDisplayedScrollingRowIndex ?

8 posts, 1 answers
  1. guillaumeGL
    guillaumeGL avatar
    6 posts
    Member since:
    May 2009

    Posted 26 Nov 2009 Link to this post

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

    Posted 27 Nov 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. guillaumeGL
    guillaumeGL avatar
    6 posts
    Member since:
    May 2009

    Posted 27 Nov 2009 Link to this post

    It do the trick, thank you !

    Guillaume.
    Adiial
  5. Rawad
    Rawad avatar
    23 posts
    Member since:
    Jan 2012

    Posted 22 Aug Link to this post

    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 ?

  6. Rawad
    Rawad avatar
    23 posts
    Member since:
    Jan 2012

    Posted 22 Aug Link to this post

    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 ?

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 22 Aug Link to this post

    Hi Rawad,

    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 at 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.
  8. Rawad
    Rawad avatar
    23 posts
    Member since:
    Jan 2012

    Posted 24 Aug Link to this post

    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

  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 25 Aug Link to this post

    Hi Rawad,

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready