Esempio n. 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;
     }
 }
Esempio n. 2
0
        // This method creates another enumerator that contains the same enumeration
        // state as the current one. Using this function, a client can record a
        // particular point in the enumeration sequence and return to that point at a
        // later time. The new enumerator supports the same interface as the original one.
        public void Clone(
            out UCOMIEnumString ppenum)             // Address of the IEnumString pointer
                                                    // variable that receives the interface
                                                    // pointer to the enumeration object. If
                                                    // the method  is unsuccessful, the value
                                                    // of this output variable is undefined.
        {
            SourceCustomList clone = new SourceCustomList
            {
                currentPosition = currentPosition,
                StringList      = (String[])StringList.Clone()
            };

            ppenum = clone;
        }
Esempio n. 3
0
        public static void Enable(IntPtr controlHandle, SourceCustomList items, AUTOCOMPLETEOPTIONS options)
        {
            if (controlHandle == IntPtr.Zero)
            {
                return;
            }

            IAutoComplete2 iac = null;

            try
            {
                iac = (IAutoComplete2)GetAutoComplete();
                int ret = iac.Init(controlHandle, items, "", "");
                ret = iac.SetOptions(options);
                ret = iac.Enable(true);
            }
            finally
            {
                if (iac != null)
                {
                    Marshal.ReleaseComObject(iac);
                }
            }
        }