From e079be0ad7e74e5a8483e5c10be19857f2035311 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sun, 15 May 2022 11:27:49 -0600 Subject: [PATCH] Make scrll look more natural when removing items from control --- Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs index e942def1..d031d191 100644 --- a/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs +++ b/Source/LibationWinForms/ProcessQueue/VirtualFlowControl.cs @@ -190,7 +190,10 @@ namespace LibationWinForms.ProcessQueue vScrollBar1.LargeChange = LargeScrollChange; //https://stackoverflow.com/a/2882878/3335599 - vScrollBar1.Maximum = VirtualHeight + vScrollBar1.LargeChange - 1; + int newMaximum = VirtualHeight + vScrollBar1.LargeChange - 1; + if (newMaximum < vScrollBar1.Maximum) + vScrollBar1.Value = Math.Max(vScrollBar1.Value - (vScrollBar1.Maximum - newMaximum), 0); + vScrollBar1.Maximum = newMaximum; } }