Author SHA1 Message Date
redlineoandClaude Sonnet 5 b42815aa2a Fix add/remove template buttons overlapping the list (Dock add-order bug)
WinForms docks child controls in the REVERSE of their Controls.Add()
order - the last control added gets docked first (claims its edge
space first), and earlier-added controls lay out against whatever
remains. pnlTemplateButtons (Dock=Top) was added before lstTemplates
(Dock=Fill), so Fill was processed first against the full, unclaimed
panel area and expanded to cover the whole thing - overlapping the
button strip instead of leaving room for it. Swapped the add order
(Fill first, Top second) so the button strip actually carves out its
band before Fill claims what's left.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 13:04:48 +03:00
@@ -253,12 +253,24 @@ namespace BulkArchiveMailer.AddIn.UI
this.pnlTemplateList.Size = new System.Drawing.Size(190, 467);
this.pnlTemplateList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
// Dock order matters here: pnlTemplateButtons (Dock=Top) is
// added FIRST, lstTemplates (Dock=Fill) SECOND, so the Fill
// control's layout is computed against whatever client area
// remains under the already-docked top strip.
this.pnlTemplateList.Controls.Add(this.pnlTemplateButtons);
// Dock order matters here, and it is the OPPOSITE of what looks
// intuitive: WinForms lays out docked children in the REVERSE
// of their Controls.Add() order - the LAST control added is
// docked FIRST (closest to the parent's edge), and each
// earlier-added control is then laid out against whatever
// client area is left over. So lstTemplates (Dock=Fill) must be
// added FIRST, and pnlTemplateButtons (Dock=Top) must be added
// SECOND/last, so that the Top strip is actually the one that
// gets docked last (i.e. first in effect) and carves its 35px
// band out of the top; Fill then only gets whatever remains
// below it. Adding them in the other order (as this used to be)
// makes Fill get laid out first, against the FULL panel client
// area (nothing has carved out the top strip yet), so it
// expands to cover the entire panel and visually overlaps
// pnlTemplateButtons - exactly the "buttons overlap the list"
// bug reported on the real machine.
this.pnlTemplateList.Controls.Add(this.lstTemplates);
this.pnlTemplateList.Controls.Add(this.pnlTemplateButtons);
// pnlTemplateButtons
//