Loading...
Loading...
Guides implementation of Syncfusion WinForms ComboBoxBase control with flexible, pluggable ListControl architecture. Use this when working with advanced combo box implementations requiring custom ListControl-derived controls, CheckedListBox integration, or multi-column dropdowns with GridListControl.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-comboboxbaseListControl1. Open your WinForms project in Visual Studio
2. Drag ComboBoxBase from Toolbox to Form
3. Drag ListBox from Toolbox to Form
4. In ComboBoxBase Properties, set ListControl = listBox1using Syncfusion.Windows.Forms.Tools;
using System.Windows.Forms;
public partial class Form1 : Form
{
private ComboBoxBase comboBoxBase1;
private ListBox listBox1;
public Form1()
{
InitializeComponent();
SetupComboBoxBase();
}
private void SetupComboBoxBase()
{
// Create ComboBoxBase and ListBox
comboBoxBase1 = new ComboBoxBase();
listBox1 = new ListBox();
// Configure ComboBoxBase
comboBoxBase1.Size = new Size(200, 25);
comboBoxBase1.Location = new Point(20, 20);
comboBoxBase1.ListControl = listBox1; // Connect ListBox
// Add items to ListBox
listBox1.Items.AddRange(new object[] {
"Option 1",
"Option 2",
"Option 3",
"Option 4"
});
// Add to form
this.Controls.Add(listBox1);
this.Controls.Add(comboBoxBase1);
}
}Imports Syncfusion.Windows.Forms.Tools
Imports System.Windows.Forms
Public Class Form1
Private comboBoxBase1 As ComboBoxBase
Private listBox1 As ListBox
Public Sub New()
InitializeComponent()
SetupComboBoxBase()
End Sub
Private Sub SetupComboBoxBase()
' Create ComboBoxBase and ListBox
comboBoxBase1 = New ComboBoxBase()
listBox1 = New ListBox()
' Configure ComboBoxBase
comboBoxBase1.Size = New Size(200, 25)
comboBoxBase1.Location = New Point(20, 20)
comboBoxBase1.ListControl = listBox1 ' Connect ListBox
' Add items to ListBox
listBox1.Items.AddRange(New Object() {
"Option 1",
"Option 2",
"Option 3",
"Option 4"
})
' Add to form
Me.Controls.Add(listBox1)
Me.Controls.Add(comboBoxBase1)
End Sub
End Class// Create data source
List<string> states = new List<string>
{
"California", "Texas", "Florida", "New York"
};
// Set DataSource on ListBox (not ComboBoxBase)
listBox1.DataSource = states;
comboBoxBase1.ListControl = listBox1;// Use CheckedListBox for multi-select
CheckedListBox checkedListBox1 = new CheckedListBox();
checkedListBox1.Items.AddRange(new object[] {
"Item 1", "Item 2", "Item 3", "Item 4"
});
comboBoxBase1.ListControl = checkedListBox1;
// Handle DropDownCloseOnClick to prevent premature closing
comboBoxBase1.DropDownCloseOnClick += (sender, e) => {
e.Cancel = true; // Keep dropdown open while selecting
};
// Update text with checked items
checkedListBox1.ItemCheck += (sender, e) => {
// Build text from checked items
var checkedItems = checkedListBox1.CheckedItems.Cast<object>();
comboBoxBase1.TextBox.Text = string.Join(", ", checkedItems);
};public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
// Create employee list
List<Employee> employees = new List<Employee>
{
new Employee { Id = 1, Name = "John Doe" },
new Employee { Id = 2, Name = "Jane Smith" },
new Employee { Id = 3, Name = "Bob Johnson" }
};
listBox1.DataSource = employees;
listBox1.DisplayMember = "Name"; // Display property
listBox1.ValueMember = "Id"; // Value property
comboBoxBase1.ListControl = listBox1;| Property | Type | Description |
|---|---|---|
| IListControl | Gets or sets the ListControl-derived control for dropdown |
| TextBox | Gets the TextBox portion of the control |
| PopupControlContainer | Gets the popup container for dropdown |
| ComboBoxStyle | Gets or sets the visual style |
| FlatStyle | Gets or sets the flat style appearance |
| Size | Gets or sets the control size |
| Property | Type | Description |
|---|---|---|
| ObjectCollection | Collection of items in the list |
| object | Data source for the list |
| string | Property to display for objects |
| string | Property to use as value |
| object | Currently selected item |
| int | Currently selected index |
| SelectionMode | Single or multiple selection |
| Event | Description |
|---|---|
| Fires when selection is committed by user action |
| Fires when dropdown is about to close on click (cancellable) |
| Fires when dropdown is opening |
SelectedIndexChanged