Hi,

I'm wondering is there any build-in function or component that I can use to create a multi-select dropdown combobox. I try to google for this but most of the solution I found is for web based software. I'm not asking for the whole program. At least something for me to start from?? :'(

Thanks...

Dani AI

Generated

Given the WinForms context (as assumed) and the long-list / limited-space constraint raised by , a compact, practical pattern is to keep the main combobox small and host a scrollable CheckedListBox (or a checked ListView) inside the dropdown. That keeps the UI tidy while letting users scan and tick many entries without eating screen real estate.

Key implementation points to consider:

  • Summary in the combobox: show the first 1–3 selected items then “+N more” or simply “3 selected” so the control stays compact.
  • In-dropdown filtering: a small textbox at the top of the popup (type-to-filter) is essential for long lists.
  • Convenience actions: add “Select all” / “Clear” options and keyboard support (arrow keys, space to toggle).
  • Performance: for thousands of items use virtualization (WinForms VirtualMode or WPF virtualization) or server-side incremental search to avoid slow loads.
  • Accessibility: preserve proper focus behavior so the popup doesn’t close on every click and ensure keyboard/screen-reader usability.

A minimal WinForms example that shows the idea (ComboBox that drops a CheckedListBox via a ToolStripDropDown):

using System;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;

public class MultiSelectComboBox : ComboBox
{
    private CheckedListBox _clb = new CheckedListBox();
    private ToolStripControlHost _host;
    private ToolStripDropDown _drop;

    public MultiSelectComboBox()
    {
        DropDownStyle = ComboBoxStyle.DropDown;
        _clb.CheckOnClick = true;
        _host = new ToolStripControlHost(_clb) { Margin = Padding.Empty };
        _drop = new ToolStripDropDown { Padding = Padding.Empty, AutoClose = true };
        _drop.Items.Add(_host);
        _clb.ItemCheck += (s,e) => BeginInvoke(new Action(UpdateText));
    }

    protected override void OnMouseDown(MouseEventArgs e)
    {
        base.OnMouseDown(e);
        _clb.Width = Width;
        _clb.Height = 160;
        _host.Size = _clb.Size;
        if (_drop.Visible) _drop.Close();
        else _drop.Show(this, 0, Height);
    }

    private void UpdateText()
    {
        var checkedItems = _clb.CheckedItems.Cast<object>().Select(o => o.ToString()).ToArray();
        Text = checkedItems.Length == 0 ? string.Empty
             : checkedItems.Length <= 3 ? string.Join(", ", checkedItems)
             : checkedItems[0] + " +" + (checkedItems.Length - 1) + " more";
    }

    public CheckedListBox CheckedList => _clb;
}

Troubleshooting notes: ensure the popup width/height are set before showing, use BeginInvoke in ItemCheck to read the new state, and handle focus/closing so clicks inside the popup don’t immediately dismiss it. For WPF the same pattern is a Popup hosting a multi-select ListBox with virtualization enabled. Third-party suites are available if a production-ready control is preferred, but the pattern above is easy to implement and tailor.

Recommended Answers

All 3 Replies

why not use a listview? or checkbox group?

I got a very long list of items... Checkbox will looks a bit messy. Another problem is I have limited space...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.