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
Actually I originally tried radTextBoxControl1.AutoCompleteDataSource = items;
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.
Dimitar
Progress Telerik
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).
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
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
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.
Dimitar
Progress Telerik
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);
}
}
I am glad that this works now. Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Progress Telerik