Combobox with checkbox in winforms

…衆ロ難τιáo~ 提交于 2019-12-18 16:16:53

问题


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.

If anybody has a good link for a sample which does not require a license. Please let me know.

I am not looking for controls like telerik and infragistics.


回答1:


Maybe this example can help you.

CheckBox ComboBox Extending the ComboBox Class and Its Items




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/8622338/combobox-with-checkbox-in-winforms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!