Example #1
0
        /// <summary>Sets a custom automatic complete list.</summary>
        /// <param name="textBox">The text box.</param>
        /// <param name="items">The autocomplete strings.</param>
        /// <param name="options">The autocomplete options.</param>
        public static void SetCustomAutoCompleteList(this TextBox textBox, IList <string> items, AUTOCOMPLETEOPTIONS options = AUTOCOMPLETEOPTIONS.ACO_AUTOSUGGEST)
        {
            var ac = new IAutoComplete2();

            ac.Init(textBox.Handle, new ComEnumStringImpl(items), null, null);
            ac.SetOptions(options);
        }
Example #2
0
 protected override void CreateHandle()
 {
     base.CreateHandle();
     autoComplete         = (IAutoComplete2) new IAutoComplete();
     autoCompleteDropDown = (IAutoCompleteDropDown)autoComplete;
     autoComplete.SetOptions(AutoCompleteOptions.AutoSuggest);
     autoComplete.Init(new HandleRef(this, this.Handle), new EnumString(new string[] { "Administrator", "Clerk" }), null, null);
 }
Example #3
0
        /// <summary>
        /// Enable/Disable auto complete.
        /// </summary>
        /// <param name="enable">bool</param>
        /// <param name="quickComplete">string. Use null to disable CTRL-ENTER handling</param>
        /// <remarks>CTRL-ENTER seems to have a bug: it also expands already expanded Urls of the form 'http://xyz.domain'</remarks>
        public void SetAutoComplete(Boolean enable, string quickComplete)
        {
            Int32          ret;
            IAutoComplete2 iac2 = (IAutoComplete2)GetAutoComplete();

            if (EditHandle == IntPtr.Zero)
            {
                throw new Exception("EditHandle must not be zero!");
            }

            if (ListSource == null)
            {
                throw new Exception("ListSource must not be null!");
            }

            ret = iac2.Init(EditHandle, ListSource, "", quickComplete);

            ret = iac2.SetOptions((UInt32)ACOptions);

            ret = iac2.Enable(enable ? 1 : 0);

            Marshal.ReleaseComObject(iac2);
        }
Example #4
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);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Enables the specified control handle.
        /// </summary>
        /// <param name="controlHandle">The control handle.</param>
        /// <param name="items">The items.</param>
        /// <param name="options">The options.</param>
        private static void Enable(IntPtr controlHandle, SourceCustomList items, AUTOCOMPLETEOPTIONS options)
        {
            if (controlHandle == IntPtr.Zero)
            {
                return;
            }

            IAutoComplete2?iac = null;

            try
            {
                iac = GetAutoComplete() as IAutoComplete2;
                iac?.Init(controlHandle, items, string.Empty, string.Empty);
                iac?.SetOptions(options);
                iac?.Enable(true);
            }
            finally
            {
                if (iac != null)
                {
                    Marshal.ReleaseComObject(iac);
                }
            }
        }