Hello, I have a windows application written on visual studio 2008. I have a textbox that has autocompleteMode set to suggest, autocompleteSource set to CustomSource. So I triiger the textchanged event on the textbox to add the autocomplete datasource for the textbox like this:
private void txtSearch_TextChanged(object sender, EventArgs e)
{
AutoCompleteStringCollection result = new AutoCompleteStringCollection();
//do my logic too add the list of items to result
txtSearch.AutoCompleteCustomSource = result;
}
This was working fine, now I want the search button to be perform click when the user press enter in the textbox, so I added another event handler for the textbox like this
private void txtSearch_keypress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar ==(char)( Keys.Enter))
{
cmdSearch.PerformClick();
e.Handled = true;
}
}
also in the main windows form class I added the following to trigger the above keypress event:
this.txtSearch.KeyPress += new KeyPressEventHandler(this.txtSearch_keypress);
Now when the user type in anything, both event is raised, but as soon as they select one of the suggested result and press enter, it is not doing anything. I am doing some thing wrong, any help would be appreciated, I was working on website for so long and seems to forget everything about windos app now. Thanks