Hi Jason,
One solution that comes to my mind is to override the method inserting this text in the AutoCompleteBoxViewElement. To do that you need to create a descendant of the control, the RadAutoCompleteBoxElement and the AutoCompleteBoxViewElement. Here is the code for this:
class
MyAutoCompleteBox : RadAutoCompleteBox
{
protected
override
RadTextBoxControlElement CreateTextBoxElement()
{
return
new
MyRadAutoCompleteBoxElement();
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadAutoCompleteBox).FullName;
}
}
}
class
MyRadAutoCompleteBoxElement : RadAutoCompleteBoxElement
{
protected
override
TextBoxViewElement CreateViewElement()
{
return
new
MyAutoCompleteBoxViewElement();
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadAutoCompleteBoxElement);
}
}
}
class
MyAutoCompleteBoxViewElement : AutoCompleteBoxViewElement
{
protected
override
int
InsertTokenizedTextBlocks(
int
index,
string
text,
bool
performInvalidation)
{
if
(
this
.OnTokenValidating(text) ==
false
)
{
return
-1;
}
StringBuilder textBuilder =
new
StringBuilder();
for
(
int
i = 0; i < text.Length; i++)
{
char
symbol = text[i];
bool
isDelimiter = symbol ==
this
.Delimiter;
if
(isDelimiter)
{
if
(textBuilder.Length > 0)
{
string
blockText = textBuilder.ToString();
bool
isValid =
true
;
if
(isValid)
{
ITextBlock textBlock =
this
.CreateBlock(blockText, TokenizedTextBlockElementType);
textBlock.Index = index;
this
.Children.Insert(index, textBlock
as
RadElement);
}
else
{
textBuilder.Append(symbol);
blockText = textBuilder.ToString();
index =
base
.InsertTextBlocks(index, blockText, TextBlockElementType);
}
index++;
textBuilder =
new
StringBuilder();
}
continue
;
}
else
if
(symbol == TextBoxViewElement.LineFeedSymbol ||
symbol == TextBoxViewElement.CarriageReturnSymbol)
{
if
(textBuilder.Length >= 0)
{
textBuilder.Append(symbol);
index =
base
.InsertTextBlocks(index, textBuilder.ToString(), TextBlockElementType) + 1;
textBuilder =
new
StringBuilder();
continue
;
}
}
textBuilder.Append(symbol);
}
if
(textBuilder.Length > 0)
{
index =
base
.InsertTextBlocks(index, textBuilder.ToString(), TextBlockElementType) + 1;
}
return
index - 1;
}
}
Let me know how this works for you.
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application.
Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>