Hi Oscar,
Thank you for writing.
This can be easily achieved by adding a new
RadListDataItem to the collection filling your
RadAutoCompleBox. You only have to extract the correct string from the editor. Please check my code snippet below:
public
partial
class
Form1 : Form
{
private
RadListDataItemCollection items;
public
Form1()
{
InitializeComponent();
this
.items =
this
.radAutoCompleteBox1.AutoCompleteItems;
this
.items.Add(
new
RadListDataItem(
"Joe Smith"
));
this
.items.Add(
new
RadListDataItem(
"Adam Petersen"
));
this
.items.Add(
new
RadListDataItem(
"Jack Russel"
));
this
.items.Add(
new
RadListDataItem(
"Daniel Finger"
));
this
.items.Add(
new
RadListDataItem(
"Richard Vail"
));
this
.items.Add(
new
RadListDataItem(
"Sebastian Jonnson"
));
this
.items.Add(
new
RadListDataItem(
"Lee Cooper"
));
this
.items.Add(
new
RadListDataItem(
"Kelvin Clain"
));
this
.items.Add(
new
RadListDataItem(
"Maria Jenson"
));
this
.items.Add(
new
RadListDataItem(
"Chelsea Maarten"
));
this
.items.Add(
new
RadListDataItem(
"Jenson Chew"
));
this
.items.Add(
new
RadListDataItem(
"Martin Williams"
));
this
.items.Add(
new
RadListDataItem(
"Telerik"
));
this
.items.Add(
new
RadListDataItem(
"James Stone"
));
this
.items.Add(
new
RadListDataItem(
"Samuel Jackson"
));
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
int
lastIndexOfToken =
this
.radAutoCompleteBox1.Text.LastIndexOf(
";"
);
string
newItem;
if
(lastIndexOfToken > 0)
{
newItem =
this
.radAutoCompleteBox1.Text.Substring(lastIndexOfToken + 1);
}
else
{
newItem =
this
.radAutoCompleteBox1.Text;
}
this
.items.Add(
new
RadListDataItem(newItem));
}
}
I am also sending you a short video showing the result on my end.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik