Skip to content

Commit

Permalink
Fix InvalidOperationException startup crash on systems with unusual DPI
Browse files Browse the repository at this point in the history
Fixes #425
  • Loading branch information
Klocman committed Mar 4, 2023
1 parent 67922bc commit 3e92322
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/ObjectListView/ObjectListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11836,8 +11836,13 @@ protected override void RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNe

Font = new Font(Font.FontFamily, MathF.Round(origFontSize * scalingRatio, 1));

foreach (OLVListItem listViewItem in Items)
// Can't use foreach since it can throw an InvalidOperationException when the ListView is in virtual mode
for (var i = 0; i < Items.Count; i++)
{
var listViewItem = (OLVListItem)Items[i];
RefreshItem(listViewItem);
}

AutoResizeColumns();

EndUpdate();
Expand Down

0 comments on commit 3e92322

Please sign in to comment.