Category / Section
How to bind ArrayList to WinForms ComboBox AutoComplete?
1 min read
Bind the Arraylist
You can bind the ArrayList with ComboBoxAutoComplete by using the DataSource property.
C#
private void Form1_Load(object sender, EventArgs e)
{
this.alphaList.AddRange(new String[]{"A","B","C","D","E"});
foreach (string s in this.alphaList)
{
for (int i = 0; i < 5; i++)
{
this.itemsList.Add(s + i.ToString());
}
}
this.comboBoxAutoComplete1.AutoCompleteControl.DataSource = this.itemsList;
this.comboBoxAutoComplete1.DropDownWidth = this.comboBoxAutoComplete1.Width;
}
VB
Private Sub Form1_Load(sender As Object, e As EventArgs)
Me.alphaList.AddRange(New [String]() {"A", "B", "C", "D", "E"})
For Each s As String In Me.alphaList
For i As Integer = 0 To 4
Me.itemsList.Add(s & i.ToString())
Next
Next
Me.comboBoxAutoComplete1.AutoCompleteControl.DataSource = Me.itemsList
Me.comboBoxAutoComplete1.DropDownWidth = Me.comboBoxAutoComplete1.Width
End Sub
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ComboBoxbinding_(2)-1271859133.zip