Autocompletebox item count limit and validation

4 posts, 0 answers
  1. Luis
    Luis avatar
    4 posts
    Member since:
    Apr 2016

    Posted 20 May Link to this post

    Hello there!

     

    Im trying to accomplish these 2 taks:

     

     -  To limit the amount of items added by the AutoCompleteBox

    -  To retrieve the AutoCompleteValueMember after a TextBlock is added

     

    So far i tried with the event CreateTextBlock but, the event fires every time i type a key , i was looking the documentation and i cant seem to find an event that fires after a TextBlock is added.

     

    Any help would be appreciated.

    Thanks.

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 25 May Link to this post

    Hello Luis,

    Thank you for writing. 

    In order to limit the tokens, you can use the RadAutoCompleteBox.TokenValidating event and set the TokenValidatingEventArgs.IsValidToken property to false if the RadAutoCompleteBox.Items collection exceeds the limit.

    As to the question about detecting when a token is created, indeed, the CreateTextBlock event is appropriate. However, you need to check the TextBlock:
    private void radAutoCompleteBox1_CreateTextBlock(object sender, Telerik.WinControls.UI.CreateTextBlockEventArgs e)
    {
        if (e.TextBlock is TokenizedTextBlockElement)
        {
            //TODO
        }
    }


    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Luis
    Luis avatar
    4 posts
    Member since:
    Apr 2016

    Posted 26 May in reply to Dess Link to this post

    Thanks for the answer, but i found another workaround earlier.

     

    Thanks anyways.

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 31 May Link to this post

    Hello Luis,

    Thank you for writing back. 

    I am glad that you have found a suitable solution for your case. Feel free to share it in the forum in order the community to benefit from it. Thank you in advance.

    If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top