Hello Terry,
You can achieve your scenario by extending the RadAutoComplteBox. You should create a custom list element where you can alter the filtering logic. In addition, you should create a custom list element to represent an item with two columns:
public
class
CustomTextBoxListElement : RadTextBoxListElement
{
public
CustomTextBoxListElement()
{
this
.CreatingVisualItem +=
this
.OnCreatingVisualItem;
}
private
void
OnCreatingVisualItem(
object
sender, CreatingVisualListItemEventArgs args)
{
args.VisualItem =
new
CustomVisualItem();
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadListElement);
}
}
protected
override
bool
AutoCompleteFilter(RadListDataItem item)
{
if
(
this
.AutoCompleteMode != System.Windows.Forms.AutoCompleteMode.Suggest)
{
return
base
.AutoCompleteFilter(item);
}
RadTextBoxAutoCompleteDropDown popup =
this
.ElementTree !=
null
?
this
.ElementTree.Control
as
RadTextBoxAutoCompleteDropDown :
null
;
if
(popup !=
null
&& popup.OwnerElement.ElementTree.Control.Site !=
null
)
{
return
true
;
}
if
(
string
.IsNullOrEmpty(
this
.PatternText))
{
return
false
;
}
string
itemText = (item.Text ??
string
.Empty).ToUpperInvariant();
string
[] splittedWords = itemText.Split(
new
char
[] {
' '
}, StringSplitOptions.RemoveEmptyEntries);
string
patternText =
this
.PatternText.ToUpperInvariant();
foreach
(
string
word
in
splittedWords)
{
if
(word.StartsWith(patternText))
{
return
true
;
}
}
return
false
;
}
}
public
class
CustomVisualItem : RadListVisualItem
{
private
StackLayoutElement element;
private
LightVisualElement firstColumn;
private
LightVisualElement lastColumn;
private
LightVisualElement separator;
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.element =
new
StackLayoutElement();
this
.element.StretchHorizontally =
true
;
this
.element.StretchVertically =
true
;
this
.firstColumn =
new
LightVisualElement();
this
.firstColumn.StretchHorizontally =
false
;
this
.firstColumn.MinSize =
new
Size(40, 0);
this
.lastColumn =
new
LightVisualElement();
this
.lastColumn.TextAlignment = ContentAlignment.MiddleLeft;
this
.separator =
new
LightVisualElement();
this
.separator.StretchHorizontally =
false
;
this
.separator.MinSize =
new
System.Drawing.Size(2, 0);
this
.separator.BackColor = Color.FromArgb(156, 189, 232);
this
.separator.GradientStyle = GradientStyles.Solid;
this
.separator.DrawText =
false
;
this
.separator.DrawFill =
true
;
this
.element.Children.Add(
this
.firstColumn);
this
.element.Children.Add(
this
.separator);
this
.element.Children.Add(
this
.lastColumn);
this
.Children.Add(
this
.element);
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadListVisualItem);
}
}
public
override
void
Synchronize()
{
base
.Synchronize();
this
.DrawText =
false
;
this
.firstColumn.Text = Convert.ToString(
this
.Data.Value);
this
.lastColumn.Text =
this
.Data.Text;
}
}
Let me know if you need further assistance.
Kind regards,
Svett
the Telerik team