Hello Randy,
Thank you for writing.
RadDropDownList without its arrow button will be perfect for this case. You can create a custom AutoCompleteSuggest helper which will take the items from a remote database instead of filtering existing ones, in my example it will take them from a collection. Please, refer to the code below:
public
partial
class
Form1 : Form
{
List<
string
> serverSideItems =
new
List<
string
>();
public
Form1()
{
InitializeComponent();
Enumerable.Range(0, 5000).ToList().ForEach(x => serverSideItems.Add(
"Item "
+ x));
RadDropDownList list =
new
RadDropDownList
{
Parent =
this
,
Dock = DockStyle.Top,
};
list.DropDownListElement.ArrowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
list.AutoCompleteMode = AutoCompleteMode.Suggest;
list.DropDownListElement.AutoCompleteSuggest =
new
ServerAutoCompleteSuggestHelper(list.DropDownListElement, serverSideItems);
}
}
class
ServerAutoCompleteSuggestHelper : AutoCompleteSuggestHelper
{
private
IList<
string
> serverSideItems;
private
bool
endingUpdate;
public
ServerAutoCompleteSuggestHelper(RadDropDownListElement owner, IList<
string
> serverSideItems)
:
base
(owner)
{
this
.serverSideItems = serverSideItems;
}
protected
override
void
SyncOwnerElementWithSelectedIndex()
{
if
(!endingUpdate)
{
base
.SyncOwnerElementWithSelectedIndex();
}
else
{
this
.endingUpdate =
false
;
}
}
public
override
void
ApplyFilterToDropDown(
string
filter)
{
this
.DropDownList.ListElement.BeginUpdate();
this
.DropDownList.ListElement.Items.Clear();
List<
string
> newItems = serverSideItems.AsParallel().Where(x => x.Contains(filter)).ToList();
newItems.ForEach(x =>
this
.DropDownList.ListElement.Items.Add(
new
RadListDataItem(x)));
this
.endingUpdate =
true
;
this
.DropDownList.ListElement.EndUpdate();
}
}
Feel free to modify it as you like, since the current implementation is just a mere example.
As a side note, in order to allow RadDropDownList refresh when its data source changes it should be a BindingList, since a simple List does not support notifications.
Let me know, should you have other questions.
Regards,
George
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time.
Watch the videos and start improving your app based on facts, not hunches.