mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-05-09 12:51:54 -05:00
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DSPRE {
|
|
public partial class InputComboBox : ComboBox {
|
|
private Color normalColor;
|
|
|
|
public InputComboBox() {
|
|
normalColor = this.BackColor;
|
|
DropDownStyle = ComboBoxStyle.DropDown;
|
|
|
|
AutoCompleteMode = AutoCompleteMode.SuggestAppend;
|
|
AutoCompleteSource = AutoCompleteSource.ListItems;
|
|
}
|
|
|
|
private void UpdateText() {
|
|
string input = Text;
|
|
int index = FindStringExact(input.Trim());
|
|
if (index == -1) {
|
|
this.BackColor = Color.IndianRed;
|
|
} else {
|
|
this.BackColor = normalColor;
|
|
SelectedIndex = index;
|
|
}
|
|
}
|
|
protected override void OnKeyDown(KeyEventArgs e) {
|
|
base.OnKeyDown(e);
|
|
|
|
if (e.KeyCode == Keys.Enter) {
|
|
UpdateText();
|
|
}
|
|
}
|
|
protected override void OnLeave(EventArgs e) {
|
|
base.OnLeave(e);
|
|
UpdateText();
|
|
}
|
|
|
|
[Browsable(false)]
|
|
public new ComboBoxStyle DropDownStyle {
|
|
get { return base.DropDownStyle; }
|
|
set { base.DropDownStyle = ComboBoxStyle.DropDown; }
|
|
}
|
|
}
|
|
}
|