Limit dropdown list autocomplete textbox

  • Thread starter Thread starter HansvB69
  • Start date Start date
H

HansvB69

Guest
Hi,


I create an auto complete list for a textbox. I shows 16 values. This makes the list to long for me. Is it possible to shorten de list to 5 items?


This is what i have:


using (AutoComplete aCompleteSource = new AutoComplete())
{
AutoCompleteStringCollection DataCollection;
DataCollection = aCompleteSource.CreAutoCompleteListFromTrv(TreeViewExecuteQueries); //Create the autocomplete list for the search box
TextBoxSearchInQueryTreeView.AutoCompleteSource = AutoCompleteSource.CustomSource;
TextBoxSearchInQueryTreeView.AutoCompleteCustomSource = DataCollection;
TextBoxSearchInQueryTreeView.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
}


public class AutoComplete : IDisposable
{

public AutoCompleteStringCollection CreAutoCompleteListFromTrv(TreeView Trv)
{
if (Trv != null)
{
AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
addItems(DataCollection, Trv);

return DataCollection;
}
else
{
return null;
}
}
private void addItems(AutoCompleteStringCollection col, TreeView Trv)
{
TreeNodeCollection nodes = Trv.Nodes;
foreach (TreeNode n in nodes)
{
GetTrvNodeName(n, col);
}
}
private void GetTrvNodeName(TreeNode treeNode, AutoCompleteStringCollection col)
{
col.Add(treeNode.Name);
foreach (TreeNode tn in treeNode.Nodes)
{
GetTrvNodeName(tn, col);
}
}


#region Dispose
...
#endregion Dispose
}

Continue reading...
 
Back
Top