I have an AutoCompleteBox with a value member of ProductID and a display member of Description. I would like to allow the users to auto-search by the Description field, but when they select an item from the list, I would like the AutoComplete textbox to show the ProductID in the text block when selected. Here is the example code I am using:
radAutoCompleteProductId.AutoCompleteDisplayMember = "Description";
radAutoCompleteProductId.AutoCompleteValueMember = "ProductID";
radAutoCompleteProductId.ListElement.VisualItemFormatting += OnListElementVisualItemFormatting;
radAutoCompleteProductId.DropDownMinSize = new Size(400, 300);
radAutoCompleteProductId.AutoCompleteMode = AutoCompleteMode.Suggest;
private void OnListElementVisualItemFormatting(object sender, VisualItemFormattingEventArgs e)
{
var dataItem = e.VisualItem.Data;
e.VisualItem.Text = string.Format("{1} ({0})", dataItem.Text, dataItem.Value);
}
radAutoCompleteProductId.AutoCompleteDisplayMember = "Description";
radAutoCompleteProductId.AutoCompleteValueMember = "ProductID";
radAutoCompleteProductId.ListElement.VisualItemFormatting += OnListElementVisualItemFormatting;
radAutoCompleteProductId.DropDownMinSize = new Size(400, 300);
radAutoCompleteProductId.AutoCompleteMode = AutoCompleteMode.Suggest;
private void OnListElementVisualItemFormatting(object sender, VisualItemFormattingEventArgs e)
{
var dataItem = e.VisualItem.Data;
e.VisualItem.Text = string.Format("{1} ({0})", dataItem.Text, dataItem.Value);
}