diff --git a/ContextMenuManager/BluePointLilac.Controls/SelectDialog.cs b/ContextMenuManager/BluePointLilac.Controls/SelectDialog.cs index 0002e0d..bf75e36 100644 --- a/ContextMenuManager/BluePointLilac.Controls/SelectDialog.cs +++ b/ContextMenuManager/BluePointLilac.Controls/SelectDialog.cs @@ -69,6 +69,8 @@ public string[] Items { cmbItems.Items.Clear(); cmbItems.Items.AddRange(value); + // Recalculate layout after items are added to accommodate auto-sized combobox + AdjustLayout(); } } @@ -124,8 +126,14 @@ private void InitializeComponents() Controls.AddRange(new Control[] { cmbItems, btnOK, btnCancel }); var a = 20.DpiZoom(); cmbItems.Left = a; - cmbItems.Width = 85.DpiZoom(); cmbItems.Top = btnOK.Top = btnCancel.Top = a; + // Layout will be adjusted when items are added via the Items property setter + } + + private void AdjustLayout() + { + var a = 20.DpiZoom(); + // Position buttons after combobox (which may have auto-adjusted its width) btnOK.Left = cmbItems.Right + a; btnCancel.Left = btnOK.Right + a; ClientSize = new Size(btnCancel.Right + a, btnCancel.Bottom + a);