Autosize dropdown width for met locations

BDSP locations are pretty long.
This commit is contained in:
Kurt 2021-11-24 13:14:02 -08:00
parent 26c2b8cbbc
commit 29579d7b22
2 changed files with 6 additions and 2 deletions

View file

@ -1541,7 +1541,6 @@
//
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 @@
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);

View file

@ -1242,9 +1242,15 @@ namespace PKHeX.WinForms.Controls
{
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<ComboItem> items, Font f) =>
items.Max(z => TextRenderer.MeasureText(z.Text, f).Width) +
SystemInformation.VerticalScrollBarWidth;
if (FieldsLoaded)
{