Home Forums WPF controls Xceed DataGrid for WPF editing and grid loses focus

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

    Hi,

    If I am editing a cell and I click away from the grid that cell/row remains in edit mode. Is there a simple way to accept changes to the current row when the grid loses focus?

    ‘simple’ means setting a property and not handling an event like LostFocus etc. I can do that, but I’m wondering if there’s an edit mode setting or something that deals with this.

    thanks

    Imported from legacy forums. Posted by Jack (had 2402 views)

    User (Old forums)
    Member
    Post count: 23064

    I had a similar issue and came up with the following solution.

    1) get the current datarow as per the SelectedIndex value.
    2) call the EndEdit() method on the data row.

    ————

    private void GridEndEdit()
    {
    DataRow currentRow =
    tradeViewGrid.GetContainerFromIndex(tradeViewGrid.SelectedIndex) as DataRow;
    if (currentRow != null) currentRow.EndEdit();
    }

    Imported from legacy forums. Posted by Greg (had 365 views)

    User (Old forums)
    Member
    Post count: 23064

    thanks greg,

    I’ve just tried to implement this, but get this strange(?) behaviour;

    the LostFocus event only fires when changing rows WITHIN the grid. It does not fire when focus changes from the grid another element.

    <xcdg:DataGridControl x:Name=”grid” LostFocus=”GridEndEdit” >

    private void GridEndEdit(object sender, RoutedEventArgs e)
    {
    DataRow currentRow = grid.GetContainerFromIndex(grid.SelectedIndex) as DataRow;
    if (currentRow != null) currentRow.EndEdit();
    }

    Imported from legacy forums. Posted by Jack (had 3461 views)

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