Remove dropdown on keypress

quality of life improvement
This commit is contained in:
Kurt 2020-05-08 11:26:37 -07:00
parent 8e4e0a92f8
commit e7e01ba007
3 changed files with 7 additions and 0 deletions

View File

@ -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
//

View File

@ -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);
}
}

View File

@ -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<T>() where T : Form => (T?)Application.OpenForms.Cast<Form>().FirstOrDefault(form => form is T);
public static void RemoveDropCB(object sender, KeyEventArgs e) => ((ComboBox)sender).DroppedDown = false;
}
}