From e7e01ba007376fe7fb9ab66c96ebdf0a38dd1cf4 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 8 May 2020 11:26:37 -0700 Subject: [PATCH] Remove dropdown on keypress quality of life improvement --- NHSE.WinForms/Controls/ItemEditor.Designer.cs | 3 +++ NHSE.WinForms/Controls/ItemEditor.cs | 2 ++ NHSE.WinForms/Util/WinFormsUtil.cs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/NHSE.WinForms/Controls/ItemEditor.Designer.cs b/NHSE.WinForms/Controls/ItemEditor.Designer.cs index 31a3cd0..7b87bad 100644 --- a/NHSE.WinForms/Controls/ItemEditor.Designer.cs +++ b/NHSE.WinForms/Controls/ItemEditor.Designer.cs @@ -102,6 +102,7 @@ private void InitializeComponent() this.CB_ItemID.Size = new System.Drawing.Size(141, 21); this.CB_ItemID.TabIndex = 1; this.CB_ItemID.SelectedValueChanged += new System.EventHandler(this.CB_ItemID_SelectedValueChanged); + this.CB_ItemID.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CB_KeyDown); // // NUD_Count // @@ -237,6 +238,7 @@ private void InitializeComponent() this.CB_Recipe.TabIndex = 14; this.CB_Recipe.Visible = false; this.CB_Recipe.SelectedValueChanged += new System.EventHandler(this.CB_CountAlias_SelectedValueChanged); + this.CB_Recipe.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CB_KeyDown); // // FLP_Controls // @@ -270,6 +272,7 @@ private void InitializeComponent() this.CB_Fossil.TabIndex = 21; this.CB_Fossil.Visible = false; this.CB_Fossil.SelectedValueChanged += new System.EventHandler(this.CB_CountAlias_SelectedValueChanged); + this.CB_Fossil.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CB_KeyDown); // // FLP_Count // diff --git a/NHSE.WinForms/Controls/ItemEditor.cs b/NHSE.WinForms/Controls/ItemEditor.cs index e772a4f..d7aff00 100644 --- a/NHSE.WinForms/Controls/ItemEditor.cs +++ b/NHSE.WinForms/Controls/ItemEditor.cs @@ -220,5 +220,7 @@ private void L_WaterDays_Click(object sender, EventArgs e) foreach (var v in Watered) v.Checked = value; } + + private void CB_KeyDown(object sender, KeyEventArgs e) => WinFormsUtil.RemoveDropCB(sender, e); } } diff --git a/NHSE.WinForms/Util/WinFormsUtil.cs b/NHSE.WinForms/Util/WinFormsUtil.cs index 325df7e..98151cf 100644 --- a/NHSE.WinForms/Util/WinFormsUtil.cs +++ b/NHSE.WinForms/Util/WinFormsUtil.cs @@ -66,5 +66,7 @@ internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines internal static int GetIndex(ListControl cb) => (int)(cb?.SelectedValue ?? 0); public static T? FirstFormOfType() where T : Form => (T?)Application.OpenForms.Cast
().FirstOrDefault(form => form is T); + + public static void RemoveDropCB(object sender, KeyEventArgs e) => ((ComboBox)sender).DroppedDown = false; } }