The new functionality should prevent duplicates to be added as tokens in the editor. An already selected item should not be visible in the popup as well. The attached 1148813-AutocompleteDuplicates.zip project features a possible custom solution.
Hello, Smisha,
If you select an item from the autocomplete suggestions and then press the down key, the text of the already selected item is added in the editable part. This case can be handled by manipulating the code in the OnKeyDown method especially in the if statement for the Keys.Down.
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
int newIndex = this.ListElement.SelectedIndex - 1;
while (newIndex > -1)
{
if (this.ListElement.Items[newIndex].Height == 0 || this.Text.Contains(this.ListElement.Items[newIndex].Text))
{
newIndex--;
continue;
}
if (newIndex > -1 && this.ListElement.Items[newIndex].Height > 0)
{
this.ListElement.SelectedIndex = newIndex;
return;
}
}
return;
}
if (e.KeyCode == Keys.Down)
{
int newIndex = this.ListElement.SelectedIndex + 1 > this.ListElement.Items.Count ? 0 : this.ListElement.SelectedIndex + 1;
while (newIndex < this.ListElement.Items.Count)
{
if (this.ListElement.Items[newIndex].Height == 0 || this.Text.Contains(this.ListElement.Items[newIndex].Text))
{
newIndex++;
continue;
}
if (newIndex < this.ListElement.Items.Count && this.ListElement.Items[newIndex].Height > 0)
{
this.ListElement.SelectedIndex = newIndex;
return;
}
}
return;
}
base.OnKeyDown(e);
}
As to the second case that was described, I was unable to observe the mentioned behavior after applying the above changes.
Note that this is a feature request and the provided sample project just demonstrates a possible approach for achieving the custom functionality and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best.
Please make sure that you cast your vote for it. The more votes an item gathers, the higher its priority becomes.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
If we select an item then press key down it will show the already selected item.
Also select an item then type first letter and press key down when it comes to this item position even if list doesn't show the item, on enter autocomplete box shows the item.