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

RadTextBoxControl auto complete

10 Answers 262 Views
TextBoxControl
This is a migrated thread and some comments may be shown as answers.
Tino
Top achievements
Rank 1
Tino asked on 12 Feb 2018, 02:10 AM

I've trying to get autocomplete working. After failing in my main project I created a test project with a single radtextboxcontrol and the following code from the docs, and I'm not getting any word suggestions.

I'd prefer to have something like

var items = new List{ "Matthew", "Mark", "Luke", "John"}

radTextBoxControl1.AutoCompleteItems.AddRange(items);

but that didn't work either.

Thanks.

 

namespace TelerikWinFormsApp1
{
    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        public RadForm1()
        {
            InitializeComponent();
 
            AddAutoCompleteItems();
        }
        private void AddAutoCompleteItems()
        {
            this.radTextBoxControl1.AutoCompleteMode = AutoCompleteMode.Suggest;
            RadListDataItemCollection autoCompleteItems = this.radTextBoxControl1.AutoCompleteItems;
 
            autoCompleteItems.Add(new RadListDataItem("Luke"));
            autoCompleteItems.Add(new RadListDataItem("Max"));
            autoCompleteItems.Add(new RadListDataItem("Adam"));
            autoCompleteItems.Add(new RadListDataItem("Henry"));
            autoCompleteItems.Add(new RadListDataItem("Jack"));
            autoCompleteItems.Add(new RadListDataItem("Ben"));
            autoCompleteItems.Add(new RadListDataItem("Tyler"));
            autoCompleteItems.Add(new RadListDataItem("Ethan"));
            autoCompleteItems.Add(new RadListDataItem("David"));
            autoCompleteItems.Add(new RadListDataItem("Mike"));
        }
    }
}

10 Answers, 1 is accepted

Sort by
0
Tino
Top achievements
Rank 1
answered on 12 Feb 2018, 02:13 AM

Actually I originally tried radTextBoxControl1.AutoCompleteDataSource = items;

 

0
Dimitar
Telerik team
answered on 12 Feb 2018, 10:09 AM
Hello Tino,

Actually, this code works on my side. I have attached a small video that shows this. Could you please check this again and let me know if it is still not working.

I am looking forward to your reply.
 
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tino
Top achievements
Rank 1
answered on 12 Feb 2018, 09:10 PM

After some experimenting it seems autocomplete doesn't work with Multiline=true on the textbox, which I need.

I have a split container with 3 panels, each with a RadTextBoxControl docked to Fill. Autocomplete works until I turn on multiline. Any workaround for this?

 

(Also I figured out the reason the code worked for you and not me is because I had the edit box docked to Fill my entire form, and I guess there was nowhere for the Suggest box to drop down).

0
Dimitar
Telerik team
answered on 13 Feb 2018, 12:00 PM
Hello Tino,

I was able to reproduce this. Currently, a multiline scenario is not supported. I have logged this case on our Feedback Portal. You can track its progress, subscribe to status changes and add your comment to it here. I have also updated your 
Telerik Points.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 23 Jul 2019, 05:25 PM
Greetings, already loaded the data for autocomplete, what event does it take to show the final text selected in autocomplete?
0
Dimitar
Telerik team
answered on 24 Jul 2019, 10:27 AM
Hello Danny,

I am not sure what you want to achieve. Could you please elaborate?

In general you can access the underlying list element like this:
public RadForm1()
{
    InitializeComponent();
     
 
    this.radTextBoxControl1.ListElement.SelectedIndexChanged += ListElement_SelectedIndexChanged;
}
 
private void ListElement_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    Console.WriteLine(radTextBoxControl1.ListElement.SelectedIndex);
}

I am looking forward to your reply.

Regards,
Dimitar
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.
0
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 26 Jul 2019, 11:05 PM
Perfect works, but it also activates when any letter is pressed and shows me zero index and I have not selected anything yet, when it is not selected it varies between 0 and -1 (vb.net)
0
Dimitar
Telerik team
answered on 29 Jul 2019, 06:17 AM
Hi Danny,

The event arguments cointan the position which allows you to avoid the case where the list is reset: 
private void ListElement_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    if (e.Position < 0)
    {
        Console.WriteLine(radTextBoxControl1.ListElement.SelectedIndex);
    }
}

Another approach would be to use the PopupClosed event:
public RadForm1()
{
    InitializeComponent();
 
    this.radTextBoxControl1.TextBoxElement.AutoCompleteDropDown.PopupClosed += AutoCompleteDropDown_PopupClosed;
 
}
 
private void AutoCompleteDropDown_PopupClosed(object sender, RadPopupClosedEventArgs args)
{
     
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
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.
0
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 29 Jul 2019, 08:17 PM

uniting the two parts is better, thank you very much for the help.

private void AutoCompleteDropDown_PopupClosed(object sender, RadPopupClosedEventArgs args)
{
    if (radTextBoxControl1.ListElement.SelectedIndex > 0)
    {
        Console.WriteLine(radTextBoxControl1.ListElement.SelectedIndex);
    }
}

0
Dimitar
Telerik team
answered on 30 Jul 2019, 08:07 AM
Hi Tino,

I am glad that this works now. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
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
TextBoxControl
Asked by
Tino
Top achievements
Rank 1
Answers by
Tino
Top achievements
Rank 1
Dimitar
Telerik team
Danny
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or