Exemple #1
0
 public static void EnableAutoSuggest(ComboBox tb, string[] suggestions)
 {
     // Create and assign the autocomplete source
     // Try to enable a more advanced settings for AutoComplete via the WinShell interface
     try
     {
         var source = new SourceCustomList()
         {
             StringList = suggestions.ToArray()
         };
         // For options descriptions see:
         // https://docs.microsoft.com/en-us/windows/desktop/api/shldisp/ne-shldisp-_tagautocompleteoptions
         var options = AUTOCOMPLETEOPTIONS.ACO_UPDOWNKEYDROPSLIST | AUTOCOMPLETEOPTIONS.ACO_USETAB |
                       /* AUTOCOMPLETEOPTIONS.ACO_AUTOAPPEND | */ AUTOCOMPLETEOPTIONS.ACO_AUTOSUGGEST | AUTOCOMPLETEOPTIONS.ACO_WORD_FILTER;
         AutoCompleteExt.Enable(tb.Handle, source, options);
     }
     catch (Exception)
     {
         // Incase of an error, let's fall back to the default
         var source = new AutoCompleteStringCollection();
         source.AddRange(suggestions);
         tb.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
         tb.AutoCompleteSource       = AutoCompleteSource.CustomSource;
         tb.AutoCompleteCustomSource = source;
     }
 }
Exemple #2
0
 public static void DisableAutoSuggest(ComboBox tb)
 {
     tb.AutoCompleteCustomSource = null;
     AutoCompleteExt.Disable(tb.Handle);
 }