Created Custom InputComboBox

This commit is contained in:
AdAstra-LD
2023-04-18 16:36:37 +02:00
parent 58795b3a6c
commit 2dbb5af387

32
DS_Map/InputComboBox.cs Normal file
View File

@@ -0,0 +1,32 @@
using System.ComponentModel;
using System.Windows.Forms;
namespace DSPRE {
public partial class InputComboBox : ComboBox {
public InputComboBox() {
DropDownStyle = ComboBoxStyle.DropDown;
AutoCompleteMode = AutoCompleteMode.SuggestAppend;
AutoCompleteSource = AutoCompleteSource.ListItems;
}
protected override void OnKeyDown(KeyEventArgs e) {
base.OnKeyDown(e);
if (e.KeyCode == Keys.Enter) {
string input = Text;
int index = FindStringExact(input.Trim());
if (index != -1) {
SelectedIndex = index;
}
}
}
[Browsable(false)]
public new ComboBoxStyle DropDownStyle {
get { return base.DropDownStyle; }
set { base.DropDownStyle = ComboBoxStyle.DropDown; }
}
}
}