1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
// Custom behaviour for the custom combo box
private void CustomComboBox_KeyPress(object sender, KeyPressEventArgs e)
{
switch ((Keys)e.KeyChar)
{
case Keys.Down:
break;
case Keys.Up:
break;
case Keys.Enter:
// Close the drop down list
this.DroppedDown = false;
// Set the current selected index to the item selected
this.SelectedIndex = this.FindString(this.Text);
break;
default:
// Set the cursor at the end of the input string
if (string.IsNullOrEmpty(this.Text) == false)
{
this.Select(this.Text.Length, 0);
}
// Open the drop down list
this.DroppedDown = true;
break;
}
} |
Partager