From cea2edb3e9e236c2622dab15954bf56a2dee6991 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 9 May 2021 12:10:32 -0700 Subject: [PATCH] Add controls in one action reduces the amount of control redraws --- PKHeX.WinForms/Controls/Slots/PokeGrid.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs index abcae6713..d69246990 100644 --- a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs +++ b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Linq; using System.Windows.Forms; using PKHeX.Drawing; @@ -56,15 +57,15 @@ private void Generate(int width, int height) { var x = padEdge + (column * (colWidth + border)); var pb = GetControl(sizeW, sizeH); - pb.SuspendLayout(); - Controls.Add(pb); pb.Location = new Point(x, y); Entries.Add(pb); } } - Width = (2 * padEdge) + border + (width * (colWidth + border)); - Height = (2 * padEdge) + border + (height * (rowHeight + border)); + int w = (2 * padEdge) + border + (width * (colWidth + border)); + int h = (2 * padEdge) + border + (height * (rowHeight + border)); + Size = new Size(w, h); + Controls.AddRange(Entries.Cast().ToArray()); Debug.WriteLine($"{Name} -- Width: {Width}, Height: {Height}"); ResumeLayout(); }