New to Telerik UI for WinForms? Download free 30-day trial

Add non-existing Items

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

this.radCheckedDropDownList1.TokenValidating += radCheckedDropDownList1_TokenValidating;

AddHandler Me.RadCheckedDropDownList1.TokenValidating, AddressOf radCheckedDropDownList1_TokenValidating

Add non-existing items

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;
        }
    }
}

Private Sub radCheckedDropDownList1_TokenValidating(sender As Object, e As TokenValidatingEventArgs)
    If Not e.IsValidToken Then
        Dim textBox As AutoCompleteBoxViewElement = TryCast(sender, AutoCompleteBoxViewElement)
        If Me.RadCheckedDropDownList1.DropDownListElement.FindStringExact(e.Text) = -1 Then
            Me.RadCheckedDropDownList1.Items.Add(New RadCheckedListDataItem(e.Text, False))
            e.IsValidToken = True
        End If
    End If
End Sub

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

WinForms RadCheckedDropDownList Tokens Validating

In this article