Skip to content

Commit

Permalink
Wpf: protect against errors in GridView.SelectedRows
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Feb 27, 2024
1 parent c130486 commit 8a3e878
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Eto.Wpf/Forms/Controls/GridHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,12 @@ public IEnumerable<int> SelectedRows
Control.SelectedItems.Clear();
foreach (int row in value)
{
Control.SelectedItems.Add(list[row]);
// protect against any incorrect info
if (row >= list.Count)
continue;
var item = list[row];
if (item != null)
Control.SelectedItems.Add(item);
}

Control.EndUpdateSelectedItems();
Expand Down

0 comments on commit 8a3e878

Please sign in to comment.