From 29579d7b22e9bc94c696555cc0a71b02acceaaaf Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 24 Nov 2021 13:14:02 -0800 Subject: [PATCH] Autosize dropdown width for met locations BDSP locations are pretty long. --- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs | 2 -- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs index d0ce1189b..c95d8e792 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs @@ -1541,7 +1541,6 @@ private void InitializeComponent() // this.CB_EggLocation.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.CB_EggLocation.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - this.CB_EggLocation.DropDownWidth = 150; this.CB_EggLocation.FormattingEnabled = true; this.CB_EggLocation.Location = new System.Drawing.Point(71, 19); this.CB_EggLocation.Name = "CB_EggLocation"; @@ -1687,7 +1686,6 @@ private void InitializeComponent() this.CB_MetLocation.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.CB_MetLocation.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.CB_MetLocation.Dock = System.Windows.Forms.DockStyle.Fill; - this.CB_MetLocation.DropDownWidth = 200; this.CB_MetLocation.FormattingEnabled = true; this.CB_MetLocation.Location = new System.Drawing.Point(98, 0); this.CB_MetLocation.Margin = new System.Windows.Forms.Padding(0); diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 14e0628fb..1e6a83436 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -1242,9 +1242,15 @@ private void ReloadMetLocations(GameVersion version, int format) { var metList = GameInfo.GetLocationList(version, format, egg: false); CB_MetLocation.DataSource = new BindingSource(metList, null); + CB_MetLocation.DropDownWidth = GetWidth(metList, CB_MetLocation.Font); var eggList = GameInfo.GetLocationList(version, format, egg: true); CB_EggLocation.DataSource = new BindingSource(eggList, null); + CB_EggLocation.DropDownWidth = GetWidth(eggList, CB_EggLocation.Font); + + int GetWidth(IEnumerable items, Font f) => + items.Max(z => TextRenderer.MeasureText(z.Text, f).Width) + + SystemInformation.VerticalScrollBarWidth; if (FieldsLoaded) {