When building Windows Forms applications, you may need a dropdown list control that allows users to select multiple items simultaneously using checkboxes, rather than limiting selection to a single item like a standard ComboBox.
Solution
You can implement multi-item selection with checkboxes in Windows Forms by using the C1MultiSelect control (available in the C1.Win.Input assembly).
Implementation Steps:
-
Add the Control: Place a
C1MultiSelectcontrol on your Form from the C1.Win.Input assembly. -
Bind or Populate Data: Bind a data collection (such as a
List<T>orBindingSource) to the control's data source. The control automatically renders checkboxes for each dropdown item and displays selected items as tags or text in the main edit area.
List<string> emails;
public NewMessageForm()
{
InitializeComponent();
// Populate data source
emails = new List<string>
{
"abc@gmail.com",
"test1@gmail.com",
"test2@gmail.com",
"xyz@gmail.com"
};
// Bind data source to control
this.bindingSource1.DataSource = emails;
this.c1MultiSelect1.DataSource = this.bindingSource1;
}