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

RadComboBox Autocomplete removes first character

4 Answers 132 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
iahulg
Top achievements
Rank 1
iahulg asked on 30 Mar 2016, 08:53 AM

Hi 
I need to implement RadComboBox Autocomplete after 2 chars entered..

After I enter the second char it removes the first char and shows the popup (see attachment).
Any ideas how to handle this ?

Codebehind:

 

1.private void RadComboBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
2.{
3.      var combo = sender as RadComboBox;
4.      if (!combo.IsDropDownOpen && combo.Text?.Length >=1)
5.         {
6.           combo.IsDropDownOpen = true;
7.         }
8.}

 

XAML:

 

01.<telerik:RadComboBox ItemsSource="{Binding PickTickets}"
02.                        DisplayMemberPath="PickTicketIdentity"
03.                        EmptyText="Please select a pick ticket"<br>
04.                        IsEditable="True"
05.                        IsFilteringEnabled="True"
06.                        TextSearchMode="Contains"
07.                        CanAutocompleteSelectItems="False"
08.                        StaysOpenOnEdit="True"
09.                        SelectedItem="{Binding SelectedPickTicket}"
10.                        KeyDown="RadComboBox_KeyDown"/> 

4 Answers, 1 is accepted

Sort by
0
Pavel
Top achievements
Rank 1
answered on 30 Mar 2016, 10:52 AM

Works with 

 private void combo_TextChanged(object sender, TextChangedEventArgs args)
{
    var combo = sender as RadComboBox;
    if (!combo.IsDropDownOpen && combo.Text?.Length >= 2)
    {
       combo.IsDropDownOpen = true;  
    }
}

 

TextBoxBase.TextChanged="combo_TextChanged" SelectAllTextEvent="None"

0
Pavel
Top achievements
Rank 1
answered on 30 Mar 2016, 10:56 AM

But doesn't work with 

CanAutocompleteSelectItems="False"

as it selects the first line with 'PK...' as soon as I enter 'pk'

 

0
Accepted
Yana
Telerik team
answered on 31 Mar 2016, 08:31 AM
Hi Vitali,

Regarding CanAutocompleteSelectItems - please note that this property is applicable only when the DropDown of the ComboBox is open.

So, in the concrete case, I have tested the provided code with a two way binding of the SelectedItem property and it is not updated when the dropdown is open and CanAutocompleteSelectItems is false.
It is expected that the first found item that match the entered text will be highlighted.

Could you please describe the expected result, so we to be able to provide proper assistance?

Regards,
Yana
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
iahulg
Top achievements
Rank 1
answered on 31 Mar 2016, 12:35 PM
Hi, Yana. 
Thanks you for your reply.
I actually managed to solve this issue using another control:
XAML:
<telerik:RadAutoCompleteBox ItemsSource="{Binding PickTickets}"
                   SelectedItem="{Binding SelectedPickTicket, Mode=TwoWay }"
                   DisplayMemberPath="PickTicketIdentity"
                   MinWidth="100"
                   TextSearchMode="Contains"
                   AutoCompleteMode="Suggest"
                   SelectionMode="Single"
                   KeyUp="RadAutoCompleteBox_KeyUp"/>

Codebehind:
private void RadAutoCompleteBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
      var racb = sender as RadAutoCompleteBox;
      if (!racb.IsDropDownOpen && racb.SearchText?.Length >= 2)
      {
          racb.IsDropDownOpen = true;
      } else if (racb.IsDropDownOpen && racb.SearchText?.Length < 2)
      {
          racb.IsDropDownOpen = false;
      }
}
Tags
ComboBox
Asked by
iahulg
Top achievements
Rank 1
Answers by
Pavel
Top achievements
Rank 1
Yana
Telerik team
iahulg
Top achievements
Rank 1
Share this question
or