adjust time to type in dropdownlist

5 posts, 0 answers
  1. Hans
    Hans avatar
    14 posts
    Member since:
    Nov 2010

    Posted 25 Nov 2013 Link to this post

    is it possible to increase the amount of time that one can type in a dropdownlist in order to 'search' for an item ?
  2. George
    Admin
    George avatar
    500 posts

    Posted 28 Nov 2013 Link to this post

    Hello Hans,

    Thank you for contacting us.

    By design RadDropDownList processes the autocomplete information on every KeyPress, however you can easily change this behavior with the following custom classes:
    public class MyDropDownList : RadDropDownList
    {
        protected override RadDropDownListElement CreateDropDownListElement()
        {
            return new MyDropDownListElement();
        }
    }
     
    public class MyDropDownListElement : RadDropDownListElement
    {
        private KeyPressEventArgs args;
     
        protected override AutoCompleteSuggestHelper CreateAutoCompleteSuggestHelper()
        {
            return new MyHelper(this, 1000);
        }
     
    }
     
    public class MyHelper : AutoCompleteSuggestHelper
    {
        private System.Windows.Forms.Timer timer;
        private string filter;
        private bool timePassed;
     
        public int AutoCompleteInterval { get; set; }
     
        public MyHelper(RadDropDownListElement owner, int interval)
            : base(owner)
        {
            this.AutoCompleteInterval = interval;
            this.timer = new System.Windows.Forms.Timer { Interval = interval };
            this.timer.Tick += timer_Tick;
        }
     
        private void timer_Tick(object sender, EventArgs e)
        {
            this.timePassed = true;
            this.HandleAutoSuggest(this.filter);
        }
     
        public override void HandleAutoSuggest(string filter)
        {
            if (this.timePassed)
            {
                base.HandleAutoSuggest(filter);
            }
     
            this.filter = filter;
            this.timer.Stop();
            this.timer.Start();
            this.timePassed = false;
        }
    }

    This will perform filtering operations one second after a user has typed something in the TextBox.

    I hope this helps.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Hans
    Hans avatar
    14 posts
    Member since:
    Nov 2010

    Posted 28 Nov 2013 Link to this post

    in the code I see 'private KeyPressEventArgs args' but I think you forgot the code that actually does something with the keypress, because the sample is not working
  5. Hans
    Hans avatar
    14 posts
    Member since:
    Nov 2010

    Posted 28 Nov 2013 Link to this post

    After much googling I found the solution:


    myDropDownList.DropDownStyle = RadDropDownStyle.DropDown;
    myDropDownList.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    myDropDownList.DropDownListElement.AutoCompleteAppend.LimitToList = true;
  6. George
    Admin
    George avatar
    500 posts

    Posted 03 Dec 2013 Link to this post

    Hello Hans,

    I am glad that you managed to resolve your problem.

    Should you need any further assistance, do not hesitate to contact us.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready