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

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)