Skip to content

Commit

Permalink
Merge pull request #2624 from cwensley/curtis/wpf-protect-GridView-Se…
Browse files Browse the repository at this point in the history
…lectedRows

Wpf: protect against errors in GridView.SelectedRows
  • Loading branch information
cwensley authored Feb 27, 2024
2 parents c130486 + 8a3e878 commit 27238c3
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 27238c3

Please sign in to comment.