This question is locked. New answers and comments are not allowed.
Hello,
I am inserting a new row (or rather a new item in the itemssource) and then set the focus on a cell in this row, so that you can edit the cell. It works fine. I found the solution in another thread in the forum.
This code ist used:
SetFocusOnCellByValue is called here:
My problem occurs, when i add a new role into the Itemssource and the column is sorted. The focus on the cell gets lost, when the new row occurs in a region, which is not visible before inserting an the GridView scrolls to the new row. You can see, that for a short moment, the cell ist selected an editable. But the focus gets lost then.
How can I solve this problem?
Thanks for help
I am inserting a new row (or rather a new item in the itemssource) and then set the focus on a cell in this row, so that you can edit the cell. It works fine. I found the solution in another thread in the forum.
This code ist used:
private void SetFocusOnCellByValue(object cellValue){ GridViewCell cell = this.GetCellByContent(cellValue); SetFocusOnCell(cell);}private GridViewCell GetCellByContent(object cellValue){ return (from cell in this.RadGridViewRoles.ChildrenOfType<GridViewCell>() where cell.Value != null && cell.Value.ToString() == cellValue.ToString() select cell).FirstOrDefault();}private void SetFocusOnCell(GridViewCell cell){ if (cell != null ) { cell.IsCurrent = true; cell.ParentRow.GridViewDataControl.CurrentColumn = cell.Column; cell.ParentRow.GridViewDataControl.CurrentItem = cell.DataContext; cell.IsInEditMode = true; }}SetFocusOnCellByValue is called here:
this.RadGridViewRoles.SelectedItem = null;RoleType newRole = new RoleType(); // Items in the Itemssource are of own typ RoleTypenewRole.displayName = "new role";items.Insert(0, newRole);this.RadGridViewRoles.SelectedItem = newRole; this.RadGridViewRoles.ScrollIntoView(newRole);SetFocusOnCellByValue("new role");My problem occurs, when i add a new role into the Itemssource and the column is sorted. The focus on the cell gets lost, when the new row occurs in a region, which is not visible before inserting an the GridView scrolls to the new row. You can see, that for a short moment, the cell ist selected an editable. But the focus gets lost then.
How can I solve this problem?
Thanks for help