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

RadAutoCompleteBox and keydown

1 Answer 215 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
jim
Top achievements
Rank 1
jim asked on 09 Aug 2018, 08:26 PM

We have a winform with a radautocompletebox. I have toggled the Autocompletemode from append to suggestappend and found that if it is set to suggestapppend and when the TAB key is pressed, the key_down event is not firing. As for the append mode, the event fires. So the question is, how can I use the suggest or suggestappend mode and when I press the TAB key the key_down event fires? The event does fire if I press the TAB key a second time.

Thank you,

Jim

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Aug 2018, 08:33 AM
Hello, Jim,      

By design, when you use Suggest or SuggestAppend AutoCompleteMode, a popup with items that match the search pattern will be shown. While the popup is opened, the KeyDown is handled internally when you press the Tab key and the popup will be closed. This is normal behavior.

If you need to handle the Tab key in this situation, you can create a a custom RadAutoCompleteBox and override the OnAutoCompleteDropDownKeyDown method in the RadAutoCompleteBoxElement. Thus, you can perform the desired logic:
  
public class CustomAutoCompleteBox : RadAutoCompleteBox
{
    public override string ThemeClassName 
    {
        get
        {
            return typeof(RadAutoCompleteBox).FullName; 
        }
    }
 
    protected override RadTextBoxControlElement CreateTextBoxElement()
    {
        return new CustomRadTextBoxControlElement();
    }
}
 
public class CustomRadTextBoxControlElement : RadAutoCompleteBoxElement
{
    protected override Type ThemeEffectiveType    
    {
        get   
        {
            return typeof(RadAutoCompleteBoxElement);    
        }
    }
 
    protected override void OnAutoCompleteDropDownKeyDown(KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Tab)
        {
        }
        base.OnAutoCompleteDropDownKeyDown(e);
    }
}

I hope this information helps. If you have any additional questions, please let me know.  
 
Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
jim
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or