sgissinger / CheckBoxComboBox

Forked from Martin Lottering project (visible on codeproject.com)

Home Page:http://www.codeproject.com/Articles/21085/CheckBox-ComboBox-Extending-the-ComboBox-Class-and

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CheckBoxComboBox

Forked from Martin Lottering project (visible on codeproject.com)

The main addition is a DataGridViewCheckBoxComboBoxColumn which allows the use of this control in a...DataGridView. And some minor corrections in order to make the control work smoothly.

It's designed to use DataSource capabilities. If the column is bound to a Dataset, the linked property must be set to Object type.

List<Status> statuses = new List<Status>();

statuses.Add(new Status(1, "New"));
statuses.Add(new Status(2, "Loaded"));
statuses.Add(new Status(3, "Inserted"));
statuses.Add(new Status(4, "Updated"));
statuses.Add(new Status(5, "Deleted"));

DataGridViewCheckBoxComboBoxColumn comboboxColumn = new DataGridViewCheckBoxComboBoxColumn();

ListSelectionWrapper<Object> wrappedList = new ListSelectionWrapper<Object>(statuses)
wrappedList.TextSeparator = comboboxColumn.TextSeparator;

comboboxColumn.DataSource = wrappedList;
comboboxColumn.ValueMember = "Selected";
comboboxColumn.DisplayMemberSingleItem = "Name";
comboboxColumn.DisplayMember = "NameConcatenated";


DataGridView dataGridView = new DataGridView();
dataGridView.Columns.Add(comboboxColumn);

[...]

var values = dataGridView[0, 0].Value as Dictionary<String, Object>;

foreach (var val in values)
{
  var wrappedVal = val.Value as ObjectSelectionWrapper<Status>;

  Status finalVal = wrappedVal.Item;
}

About

Forked from Martin Lottering project (visible on codeproject.com)

http://www.codeproject.com/Articles/21085/CheckBox-ComboBox-Extending-the-ComboBox-Class-and


Languages

Language:C# 100.0%