New to Telerik UI for WinForms? Start a free 30-day trial
Add non-existing Items
Updated over 1 year ago
There are cases where the item which the user is typing is not in the current list of items. In this case, you can manually add it.
For this purpose, RadCheckedDropDownList has the TokenValidating event. It gives you information for the token's text and whether the token, being validated, is valid. You can use this to check whether the item is already present in the items of the RadCheckedDropDownList and make the token valid:
Subscribe for TokenValidating
C#
this.radCheckedDropDownList1.TokenValidating += radCheckedDropDownList1_TokenValidating;
Add non-existing items
C#
void radCheckedDropDownList1_TokenValidating(object sender, TokenValidatingEventArgs e)
{
if (!e.IsValidToken)
{
AutoCompleteBoxViewElement textBox = sender as AutoCompleteBoxViewElement;
if (this.radCheckedDropDownList1.DropDownListElement.FindStringExact(e.Text) == -1)
{
this.radCheckedDropDownList1.Items.Add(new RadCheckedListDataItem(e.Text, false));
e.IsValidToken = true;
}
}
}
In order to make the custom text a valid token, it is necessary to enter the delimeter which is ; by default.
Figure 1: Tokens Validating
