I've experimented with your code.
As far as I can tell the Enter key is no longer handled once
txtsearch.AutoCompleteMode = AutoCompleteMode.Suggest;
has been run. Which sort of makes sense - the Enter key would be used to pick from the list of possible auto-complete entries.
As you are not filtering the autocomplete collection, why not set that up in one of the
Form_Load
or
txtsearch_Enter
events? The Enter key will still not work, but the behaviour of the text box is better.
I have no idea what the key_leave event is. If you meant the
txtSearch_Leave
event it won't help with your autocomplete.
If you really want to capture the Enter key then try using the
txtsearch_KeyUp
event instead
I also experimented with the order of the events that were fired by playing about with the order that I wired them up. It doesn't appear to be relevant - for example this order of wiring up the events
this.txtsearch.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtsearch_KeyUp);
this.txtsearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
this.txtsearch.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtSearch_KeyPress);
still resulted in the order of events
key pressed
text changed
key up
(As did the other combinations of order that I tried)