This is a migrated thread and some comments may be shown as answers.

adjust time to type in dropdownlist

5 Answers 72 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Hans asked on 25 Nov 2013, 02:44 PM
is it possible to increase the amount of time that one can type in a dropdownlist in order to 'search' for an item ?

5 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 28 Nov 2013, 12:57 PM
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 >>
0
Hans
Top achievements
Rank 1
answered on 28 Nov 2013, 02:54 PM
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
0
Hans
Top achievements
Rank 1
answered on 28 Nov 2013, 08:53 PM
After much googling I found the solution:


myDropDownList.DropDownStyle = RadDropDownStyle.DropDown;
myDropDownList.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
myDropDownList.DropDownListElement.AutoCompleteAppend.LimitToList = true;
0
George
Telerik team
answered on 03 Dec 2013, 11:59 AM
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 >>
0
Mehry
Top achievements
Rank 1
answered on 17 Mar 2020, 04:04 PM
Thank you! it works for me.
Tags
DropDownList
Asked by
Hans
Top achievements
Rank 1
Answers by
George
Telerik team
Hans
Top achievements
Rank 1
Mehry
Top achievements
Rank 1
Share this question
or