Combobox with checkbox in winforms

后端 未结 3 1235
长情又很酷
长情又很酷 2021-01-02 07:56

I am trying to look for a simple way to design a winform with a combobox that has checkbox values in it to select multiple values. But there are no free samples I could find

相关标签:
3条回答
  • 2021-01-02 08:09

    Maybe this example can help you.

    CheckBox ComboBox Extending the ComboBox Class and Its Items

    0 讨论(0)
  • 2021-01-02 08:10

    My suggestion, if space is an issue as @rmc00 has eluded to, place a button at the end of a readonly Textbox with perhaps an elipse (...) or down arrow (same as combobox) as the text of the button and when clicked or MouseDown make visible and position a CheckBoxList or open a popup dialog with a CheckBoxList this way you can either prepopulate at design time or pass a DataTable as a parameter/property to your control/form so it is databound at runtime. You can always place your control or write code to position the control/form exactly below your TextBox in the MouseDown/Click event. On check change update your textbox with a comma separated list (or go fancy and say if more than 3 items the text box can have the list stored in the Tag and the TextBox Text can have the count of items checked). Finally on LostFocus hide the Control (or Form), and further if you want to get fancy make the exception to not hide when the ActiveControl is the Button that way you can toggle the visibility of consecutive button presses.

    0 讨论(0)
  • 2021-01-02 08:12

    It sounds like what you really want is a checked listbox control or maybe even just a listbox. These controls do multi-select in a way that is more standard for Windows.

    If you really need a combo box with checkboxes in it, here's an article on code project I used once.

    0 讨论(0)
提交回复
热议问题