Home Forums WinForms controls Xceed Grid for WinForms Changing the current row Reply To: Changing the current row

User (Old forums)
Member
Post count: 23064

Hello there..

If you still haven’t found the solution for mentioned problem here it is…

After calling MoveCurrentRow, current row is changed, but it still has to be selected:

this.gridControl1.CurrentView.IsSelected = true;

This in the other hand causes previous row to remain selected, so before MoveCurrentRow call, be sure to deselect currently selected row(s):

this.gridControl1.SelectedRows.Clear();

At the end I would also recommend to call BringIntoView method, which will bring newly selected row into visible part of the grid (important on page up, page down features).

Whole method:

        protected void MoveRowCurrentRowSelection(VerticalDirection direction)
        {
            this.gridControl1.SelectedRows.Clear();

            this.gridControl1.MoveCurrentRow(direction);
            if (gridControl1.CurrentRow != null)
            {
                this.gridControl1.CurrentRow.IsSelected = true;
                this.gridControl1.CurrentRow.BringIntoView();
            }
        }

Imported from legacy forums. Posted by Ogren (had 2629 views)