From c8d874462ca07097ebce98e85b9df57a30d1b02a Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 11 Oct 2018 15:44:36 -0700 Subject: [PATCH] Clamp scroll value set Mono (Linux Mint) specific behavior; I guess 'NewValue' can be outside the range? Closes #2140 --- PKHeX.WinForms/Util/WinFormsUtil.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs index bbb4e6e69..62cbc4837 100644 --- a/PKHeX.WinForms/Util/WinFormsUtil.cs +++ b/PKHeX.WinForms/Util/WinFormsUtil.cs @@ -97,12 +97,13 @@ public static void PanelScroll(object sender, ScrollEventArgs e) switch (e.ScrollOrientation) { case ScrollOrientation.HorizontalScroll: - p.HorizontalScroll.Value = e.NewValue; + p.HorizontalScroll.Value = Clamp(e.NewValue, p.HorizontalScroll); break; case ScrollOrientation.VerticalScroll: - p.VerticalScroll.Value = e.NewValue; + p.VerticalScroll.Value = Clamp(e.NewValue, p.VerticalScroll); break; } + int Clamp(int value, ScrollProperties prop) => Math.Max(prop.Minimum, Math.Min(prop.Maximum, value)); } public static void DoubleBuffered(this DataGridView dgv, bool setting)