Home Forums WinForms controls Xceed Grid for WinForms Keeping sorted grid at top after inserting a new row

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16670 |

    I have a grid which is sorted by ID column to keep new entries at the top.  However, once the grid fills up, it stays at the bottom and the user cannot see the most recent entries without manully scrolling.

    How do I make the grid scroll to the top after each insertion?

    Imported from legacy forums. Posted by Phil (had 1093 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to get your hands on the instance of the row just inserted, and then bring it into view or set it as the current row, depending on what you want to do.

    Here is one way of doing it :

    private void Form1_Load( object sender, EventArgs e )

    {

        gridControl1.AddingDataRow +=

    new AddingDataRowEventHandler( gridControl1_AddingDataRow );

        insertionRow1.EditEnded +=

    new EventHandler( insertionRow1_EditEnded );

    }

    private Xceed.Grid.DataRow row;

    void gridControl1_AddingDataRow( object sender, AddingDataRowEventArgs e )

    {

        //keep a reference to the row being added

        row = e.DataRow;

    }

    void insertionRow1_EditEnded( object sender, EventArgs e )

    {

        row.BringIntoView();

        //or

        gridControl1.CurrentRow = row;

        gridControl1.SelectedRows.Clear();

        gridControl1.SelectedRows.Add( row );

    }

     

    Imported from legacy forums. Posted by André (had 920 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.