Home Forums WinForms controls Xceed Grid for WinForms Focusing on previously selected cell (after refreshing Grid)

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

    Hello,

    I have a simple question.

    I have a Xceed DataGrid with i.e. 5 columns and 5 rows.
    I can click with my mouse on any cell (of course) and it is focused when I click on it.
    Suppose that I have click on cell in 4th row and 4th column – it has coordinates (3,3)
    I make refresh of my grid – reload dataset.
    I want after refresh to focus on this previosly focused cell with coordinates (3,3).
    How I can do this?

    Thanks

    Imported from legacy forums. Posted by halex (had 2761 views)

    User (Old forums)
    Member
    Post count: 23064

    Somethink like:

    gridControl.AllowCellNavigation = true;

    Xceed.Grid.Cell cell = gridControl.CurrentCell;

    gridControl.refresh();

    gridControl.CurrentCell = cell;

    Imported from legacy forums. Posted by C# (had 322 views)

    User (Old forums)
    Member
    Post count: 23064

    Or like this:

    int selectedGridRowIndex = -1;
    string selectedGridCellFieldName = “”;

    if (this.gridControl1.CurrentRow != null && this.gridControl1.CurrentCell != null)
    {
    this.selectedGridRowIndex = ((Xceed.Grid.DataRow)this.gridControl1.CurrentRow).Index;
    Xceed.Grid.DataCell cell = (Xceed.Grid.DataCell)gridControl1.CurrentCell;
    this.selectedGridCellFieldName = cell.FieldName;
    }

    gridControl.refresh();

    if (this.selectedGridRowIndex != -1)
    {
    if(this.gridControl1.DataRows.Count >= this.selectedGridRowIndex)
    {
    if(this.gridControl1.DataRows[this.selectedGridRowIndex-1].Cells[this.selectedGridCellFieldName] != null)
    {
    if (((Xceed.Grid.DataCell)this.gridControl1.DataRows[this.selectedGridRowIndex-1].Cells[this.selectedGridCellFieldName]).Visible)
    {
    this.gridControl1.CurrentCell = this.gridControl1.DataRows[this.selectedGridRowIndex-1].Cells[this.selectedGridCellFieldName];
    this.gridControl1.CurrentCell.BringIntoView();
    }
    }
    }
    }

    Imported from legacy forums. Posted by C# (had 3655 views)

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