Set the current cell

As of Q1 2010 SP2 release, you are able to set the current cell of the gridview by using the CurrentCellInfo class. In the older version you could only get the current cell, but not set it.

The code below shows how to set the current cell (it will be on the sixth row and in the second column):

private void gridView_DataLoaded(object sender, EventArgs e) 
    Dispatcher.BeginInvoke(new Action(() => 
        gridView.CurrentCellInfo = new GridViewCellInfo(gridView.Items[5], gridView.Columns["Text"]); 
Private Sub gridView_DataLoaded(ByVal sender As Object, ByVal e As EventArgs) 
    Dispatcher.BeginInvoke(New Action(Sub() 
        gridView.CurrentCellInfo = New GridViewCellInfo(gridView.Items(5), gridView.Columns("Text")) 
    End Sub)) 
End Sub 

As you can see in the code above, to set the current cell you need to set the row (via the Items collection) and the column (via the Columns collection).

The screenshot below shows that the current cell is set and now if you hit F2 that cell will go in edit mode.

In this article
Not finding the help you need? Improve this article