private void AddressSuggestions_Updated(object sender, AddressSuggestionsUpdatedEventArgs eventArgs) { try { ThreadingHelpers.BeginUpdate(MyComboBox); var text = ThreadingHelpers.GetText(MyComboBox); ThreadingHelpers.ClearItems(MyComboBox); foreach (var addressSuggestions in eventArgs.AddressSuggestions) { ThreadingHelpers.AddItem(MyComboBox, addressSuggestions); } ThreadingHelpers.SetDroppedDown(MyComboBox, true); ThreadingHelpers.ClearSelection(MyComboBox); ThreadingHelpers.SetText(MyComboBox, text); ThreadingHelpers.SetSelectionStart(MyComboBox, text.Length); } catch (Exception ex) { Console.WriteLine(ex); } finally { ThreadingHelpers.EndUpdate(MyComboBox); } }
private void MyComboBox_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsControl(e.KeyChar)) { return; } var searchString = ThreadingHelpers.GetText(MyComboBox); if (searchString.Length > 1) { Task.Run(() => GetAddressSuggestions(searchString)); } }