private void _customdropdown_OtherKeyPressed(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { _customdropdown.Close(); isActivated = false; this.Invalidate(true); } }
private void _customdropdown_SelectedIndexChanged(object sender, EventArgs e) { int selectedindex = _customdropdown.SelectedIndex; _customdropdown.Close(); isActivated = false; this.Invalidate(true); if (_cbsystem.SelectedIndex != selectedindex) { _cbsystem.SelectedIndex = selectedindex; // triggers _cbsystem_SelectedIndexChanged, but only if we change the index.. } else { _cbsystem_SelectedIndexChanged(sender, e); // otherwise, fire it off manually.. this is what the system box does, if the user clicks on it, fires it off } Focus(); base.OnMouseLeave(e); // same as mouse }
// Sometimes, the user is quicker than the timer, and has commited to a selection before the results even come back. public void AbortAutoComplete() { if (waitforautotimer.Enabled) { waitforautotimer.Stop(); } else if (_cbdropdown != null) { _cbdropdown.Close(); _cbdropdown = null; Invalidate(true); } }