Winforms — multi select dropdown list

后端 未结 4 2010
Happy的楠姐
Happy的楠姐 2020-12-24 02:47

I\'m shopping around for a dropdown list control that allows me to select multiple items. Something akin to the CheckedListbox, but in dropdown list form (I don\'t want it

4条回答
  •  悲哀的现实
    2020-12-24 03:24

    Here is another solution which works better for me from a UI perspective, I find the UI more refined and code easier to use/understand:

    https://www.codeproject.com/Articles/31105/A-ComboBox-with-a-CheckedListBox-as-a-Dropdown

    Note there are a couple of fixes required to avoid the double click issue which can be found in the comments. Quoting from Herrpel (9-May-17)

    Add this to the outer class CheckedComboBox

    protected override void OnMouseDown(MouseEventArgs e)
    {
        base.OnMouseDown(e);
        DroppedDown = false;
    }
    

    and for the Windows 10 losing focus on closing the box issue, change the code in CloseDropdown: from

    ccbParent.Focus();
    this.Hide();
    

    to

    ccbParent.BeginInvoke(new MethodInvoker(() => this.Hide()));
    

提交回复
热议问题