<pre>SearchSuggestionsAPI s = new SearchSuggestionsAPI(); AutoCompleteStringCollection a = new AutoCompleteStringCollection(); private async void textBoxMain_TextChanged(object sender, EventArgs e) { textBoxMain.Focus(); textBoxMain.Select(); a = new AutoCompleteStringCollection(); if (string.IsNullOrWhiteSpace(textBoxMain.Text)) { textBoxMain.AutoCompleteCustomSource = a; return; } foreach ( GoogleSuggestion g in (IEnumerable<GoogleSuggestion>) (await s.GetSearchSuggestions(textBoxMain.Text))) { if (!string.IsNullOrWhiteSpace(g.Phrase)) { a.Add(g.Phrase); } } textBoxMain.AutoCompleteCustomSource = a; }
bool mouseOver = false; private void textBoxMain_MouseEnter(object sender, EventArgs e) { mouseOver = true; } private void textBoxMain_MouseLeave(object sender, EventArgs e) { mouseOver = false; } private void textBoxMain_Leave(object sender, EventArgs e) { if(mouseOver) { textBoxMain.Focus(); textBoxMain.Select(); textBoxMain_TextChanged(null, null); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)