Skip to content

Commit

Permalink
Wpf: Fix issue restoring column focus if the column has been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Sep 10, 2024
1 parent 9bbc8d4 commit 30e59e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Eto.Wpf/Forms/Controls/GridHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,13 @@ protected void RestoreColumnFocus()
{
Control.CurrentColumn = null;
if (Control.Columns.Count > 0)
Control.CurrentCell = new swc.DataGridCellInfo(Control.SelectedItem, CurrentColumn ?? Control.CurrentColumn ?? Control.Columns[0]);
{
// ensure the saved column still exists in the grid, it could be removed by user logic
if (CurrentColumn != null && Control.Columns.Contains(CurrentColumn))
Control.CurrentCell = new swc.DataGridCellInfo(Control.SelectedItem, CurrentColumn);
else
Control.CurrentCell = new swc.DataGridCellInfo(Control.SelectedItem, Control.CurrentColumn ?? Control.Columns[0]);
}
CurrentColumn = null;
}

Expand Down

0 comments on commit 30e59e6

Please sign in to comment.