Combobox with checkbox in windows forms

Элемент управления ComboBox (Windows Forms) ComboBox Control (Windows Forms)

ComboBox Элемент управления Windows Forms используется для вывода данных в раскрывающемся поле со списком. The Windows Forms ComboBox control is used to display data in a drop-down combo box. По умолчанию ComboBox элемент управления отображается в двух частях: Верхняя часть — это текстовое поле, позволяющее пользователю ввести элемент списка. By default, the ComboBox control appears in two parts: the top part is a text box that allows the user to type a list item. Вторая часть — это поле со списком, в котором отображается список элементов, из которых пользователь может выбрать один из них. The second part is a list box that displays a list of items from which the user can select one.

в этом разделе In This Section

Общие сведения об элементе управления ComboBox ComboBox Control Overview
Описание элемента управления, его основных возможностей и свойств. Explains what this control is and its key features and properties.

Справочник Reference

Класс ComboBox ComboBox class
Описание класса и всех его членов. Describes this class and has links to all its members.

Создание списка для выбора элементов в Windows Forms Windows Forms Controls Used to List Options
Предоставляет список действий, которые можно выполнить с помощью списков, полей со списками и списков с установленными флажками. Provides a list of things you can do with list boxes, combo boxes, and checked list boxes.

Combobox with checkbox in winforms

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.

3 Answers 3

Maybe this example can help you.

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.

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.

Читайте также:  Tkinter destroy all windows

Добавление элемента CheckBox в элемент ComboBox

По большому счёту фантастика, увидел пример в сети, у меня не получилось, не подскажите пример кривой или это не возможно, или .
_________________________________
Данный пример покажет, как можно вставить элемент CheckBox внутрь элемента ComboBox. Добавьте на форму 1 ComboBox и 1 CheckBox.

Соединение combobox и checkbox
Добрый день, Коллеги. Я сделал пользовательскую форму, в которой есть как Combobox (в котором.

CheckBox, Цикл, Массив, ComboBox | Word
Здравствуйте Коллеги! Прошу помощи(совета) в следующем вопросе. В форме Word имеется ComboBox1.

Добавить элемент списка ComboBox из ComboBox’a
Такой вопрос: вот у меня есть комбобокс с возможностью ручного ввода. Как сделать так, чтобы.

Добавление CheckBox на форму Excel
Здравствуйте! Необходима помощь с реализацией процедуры, которая позволяла бы при инициализации.

Ципихович Эндрю,
нелогично использовать в ComboBoxе флажки (выбор нескольких пунктов). ComboBox предназначен для выбора одного элемента и для отображения его в Поле.

Можно радиокнопки добавить: ListStyle: 1-fmListStyelOption

да я согласен, просто был пример в сети, меня он удивил, решил посмотреть, он ещё и не прёт

Добавлено через 29 секунд

возможно, подойдет элемент управления ListView (ToolBox — Additional controls — Microsoft ListView Control).
вот пример кода

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Добавление ComboBox и CheckBox в DBGrid
ппц это сплошная печаль, подскажите пожалуйста как сделать выпадающие списки для определенных.

Как называется штука, похожая на ComboBox, в которой напротив каждого элемента стоит CheckBox?
Не подскажете, как называется штука, похожая на ComboBox, в которой напротив каждого элемента стоит.

Добавление элемента в ComboBox со значением
Можно ли добавить в ComboBox элемент чтобы отображалось одно значение, а выбиралось другое.

Читайте также:  Можно ли вместо windows установить mac

Добавление новой строки в Edit при выборе элемента ComboBox
При выборе определенного item-а из ComboBox и занесения определенной цифры в edit надо чтобы эти.

WPF ComboBox with CheckBoxes display info about checked items?

Im trying to make a ComboBox that have checkboxes as items and based on what is checked display different things when the combobox is «closed».

The look Im trying achieve can be seen in the image.

Ideally I dont want the user to be able to select the text in the top ( in the image).

Is there a simple solution to this? I’ve seen solutions where one can display more information when all the items are shown by using DataTriggers to hide different nested controls, but that is not really what Im looking for.

3 Answers 3

Here is a way to achieve most of what you want using a ComboBox , except that the text can still be selected (using custom text only works when IsEditable is true). It is not editable though because of IsReadOnly=»true» .

View

Viewmodel

If the selectable text is an issue, you may want to create a custom ComboBox control template (default example here). Alternatively, you could use something else instead of a ComboBox , and make it look like a ComboBox .

Screenshot of example:

@Xaviers answer works 99% of the way. However the user is able to accidently select a checkbox and then the ToString() of the checkbox is shown as the selected text. This can happen quite alot actually. I havent yet worked out why this happens, but I’ve found a way to prevent this.

Create a bool property that binds to the DropDownOpen property of the combobox and when the DropDownOpen has changed to false it means that the DropDown has just been closed and you might be facing the above problem. So here you just raise the propertychanged event for the viewmodel and pass the property bound to the Text property of the combobox.

Using a combination of the @Erik83 and @Xavier solution I still had the problem that selecting a ComboBoxItem in a location right from the CheckBox text closes the ComboBox-DropDown and shows the ToString() value of the ComboBoxItem as the CheckBox is not stretched to DropDown-Width. I solved it by adding

to the CheckBox and adding the ItemContainerStyle:

Not the answer you’re looking for? Browse other questions tagged c# wpf combobox or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Читайте также:  Добавить жесткий диск линукс

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Как вставить CheckBox в ComboBox.

11 ответов

Можно воспользоваться вместо «комбобокса» ЛистВью, можно поискать библиотеки сторонних разработчиков. Я сам делал подобное из гибрида CommandButton, TextBox и ListBox. Удобнее это сделать отдельным ActiveX — проектом и откомпилить, как библиотеку, а потом использовать, как отдельный контрол. Если есть опыт, за 1 день справишься (даже быстрее).

Ты наверное имел ввиду ListBox с MultiSelect = fmMultiSelectMulti и ListStyle = fmListStyleOption?

Если нет, то я даже не представляю, как это должно выглядеть.

Я имел в виду именно ComboBox и CheckBox.
Выглядеть должно примерно так:
в выпадающем списке ползователь выбирает (чекбоксом) нужные строки, а по закрытию КомбоБокса строки переносятся в файл.

. я нарыл одно любопытное свойство КомбоБокса:
DataFormat (есть значение ЧекБокс).
. может это можно как-то использовать?

Можно воспользоваться вместо «комбобокса» ЛистВью, можно поискать библиотеки сторонних разработчиков. Я сам делал подобное из гибрида CommandButton, TextBox и ListBox. Удобнее это сделать отдельным ActiveX — проектом и откомпилить, как библиотеку, а потом использовать, как отдельный контрол. Если есть опыт, за 1 день справишься (даже быстрее).

К сожалению никогда не создавал свои компоненты, но если не трудно объяснить как это делается, то, я думаю, у меня все получится. )

Понимаешь.
. натура противная.
. я уже сам вижу, как это можно реализовать по другому, но из принцыпа хочу именно так (есть задача, значит нужно ее решить):)

Понимаешь.
. натура противная.
. я уже сам вижу, как это можно реализовать по другому, но из принцыпа хочу именно так (есть задача, значит нужно ее решить):)

Так бы сразу и сказал. 🙂

Так бы сразу и сказал. 🙂

Хорошо..
. над своей задачей подумаю сам (а прогу то писать надо):)
. вернемся к листбоксу.
в листбокс надо выгрузить большое кол-во (2000-3000) строк.
. потом надо каким-то образом отметить нужные.

Хорошо..
. над своей задачей подумаю сам (а прогу то писать надо):)
. вернемся к листбоксу.
в листбокс надо выгрузить большое кол-во (2000-3000) строк.
. потом надо каким-то образом отметить нужные.

какое свойство отвечает за состояние ЧекБокса в ЛистБоксе?

какое свойство отвечает за состояние ЧекБокса в ЛистБоксе?

:> С листбоксом разобрался.
. если у кого будут идеи, как можно отмечать элементы в выпадающем списке — пишите, буду рад любому предложению.
. спасибо всем, кто не остался равнодушным к моей проблеме. )

К сожалению никогда не создавал свои компоненты, но если не трудно объяснить как это делается, то, я думаю, у меня все получится. )

Оцените статью