Unplanned
Last Updated: 07 Apr 2023 14:18 by ADMIN
ADMIN
Vladi
Created on: 04 Sep 2014 08:22
Category: AutoCompleteBox
Type: Feature Request
2
AutoCompleteBox: Changing the SearchText when the focus is inside the control should set the caret position to the end of the new text
The default behavior when the focus is inside an input control and it's Text is changed is that it's caret is placed in the beginning of the next text. This could be observed in the WPF TextBox control.

In certain scenarios modifying the SearchText while the focus is inside the control is a desired behavior. In those scenarios the caret position is expected to be set to the end of the new text which is set to the SearchText property.
3 comments
ADMIN
Martin Ivanov
Posted on: 07 Apr 2023 14:18

Hello Julio,

Thank you taking time to share your solution. 

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Julio
Posted on: 03 Apr 2023 14:53

Is nice to see that this bug have been cought by Telerik and sad that a solution have not being found/Implemented since 2014.

 

From out side we found that only when you set the SearchText from code behind is this being a probem for us. We have not tested the AutoCompletebox without focus though. The Populate method and the userInput seems to work perfectly.

Our work around was to access the Textbox inside the control and set the caret of it to the end everytime we use code behind. 

 

```

 private static void SetCaretToTheEndByFindingTheTextboxControl(RadAutoCompleteBox completeBox)
        {
            //https://feedback.telerik.com/wpf/1352291-autocompletebox-changing-the-searchtext-when-the-focus-is-inside-the-control-should-set-the-caret-position-to-the-end-of-the-new-text
            //When completeBox.SearchText is set from code behind the caret is not changed

            if (completeBox == null)
                return;

            var textbox = completeBox.FindChildByType<TextBox>();
            if(textbox != null)
            {
                textbox.CaretIndex = textbox.Text.Length;
                return;
            }

            var waterMarkTextbox = completeBox.FindChildByType<RadWatermarkTextBox>();
            if (waterMarkTextbox != null)
            {
                waterMarkTextbox.CaretIndex = waterMarkTextbox.Text.Length;
                return;
            }
        }

```

 

Our scenario is a textbox that suggest some input but where the text displayed on the Textbox is different from the Itemlist displayed item. for that porpouse we implemented an attached property that is modifying the SearchText when the selection change (another improvement for the AutocompleteTextBox that could be easily implemented from your side) The AutocompleteBox in selection mode single was working better than suggestionBox Control.

 

ADMIN
Vladi
Posted on: 11 Sep 2014 07:48
Attached to my comment you can find a workaround project for handling the input which is entered into the TextBox of the RadAutoCompleteBox. This sample project illustrates a scenario where any 'incorrect' input is not allowed. This approach was brought to our attention by one of our users which is why we send him special thanks.
Attached Files: