Completed
Last Updated: 07 May 2013 02:27 by ADMIN
ADMIN
Stefan
Created on: 07 May 2013 02:27
Category: Editors
Type: Bug Report
0
FIX. RadAutoCompleteBox - exception when creating a TokenizedTextBlockElement with the TokenizedTextBlockElement(string text) constructor overload
To reproduce: add a token to the control and attempt adding the same token with this code in the CreateTextBlock event handler:

        void radAutoCompleteBox1_CreateTextBlock(object sender, CreateTextBlockEventArgs e)
        {
            if (e.TextBlock is TokenizedTextBlockElement)
            {
                foreach (RadListDataItem item in radAutoCompleteBox1.AutoCompleteItems)
                {
                    if (item.Text.ToLower() == e.Text.ToLower())
                    {
                        e.TextBlock = new TokenizedTextBlockElement("pepo");
                        break; // TODO: might not be correct. Was : Exit For
                    }
                }
            }
        }

Workaround:

        void radAutoCompleteBox1_CreateTextBlock(object sender, CreateTextBlockEventArgs e)
        {
            if (e.TextBlock is TokenizedTextBlockElement)
            {
                foreach (RadListDataItem item in radAutoCompleteBox1.AutoCompleteItems)
                {
                    if (item.Text.ToLower() == e.Text.ToLower())
                    {
                        TokenizedTextBlockElement element = new TokenizedTextBlockElement();
                        element.ContentElement.Text = item.Text;
                        e.TextBlock = element;
                    }
                }
            }
        }
0 comments