Dalia García Dalia García - 6 months ago 103
C# Question

How to allow more than one selection in a CheckedComboBoxEdit?

I'm working with DevExpress controls in my application. I'm using the checkedComboBoxEdit but when I want select two options, i have a invalid value error directly in the control. Someone knows why and how I can solve it?
Thanks! Nice day!

private void checkedComboBoxEdit1_EditValueChanged(object sender, EventArgs e)
foreach (int items in checkedComboBoxEdit1.Properties.Items.GetCheckedValues())

public void Prueba(RepositoryItemCheckedComboBoxEdit ri)
int cont = ri.Items.Count;
for (int i = 0; cont > i; i++)
var valor = ri.Items[i].Value;


Please go through the documentation and consider assigning this control in column of string datatype rather than some numeric column cell. From documentation: CheckedComboBoxEdit Class

The editor's edit value (BaseEdit.EditValue) identifies all the selected options in the dropdown. With the RepositoryItemCheckedComboBoxEdit.EditValueType property, you can specify whether to form the edit value as a string or a list.

Hope this information help you avoid setting incorrect value in the grid control which showing validation message for the incorrect value after doing the selection. I have modified this DX question sample by specifying the data source and behavior is same as expected after assigning a string in integer column.

RepositoryItemCheckedComboBoxEdit ccb = new RepositoryItemCheckedComboBoxEdit();
List<Student> data = new List<Student>();
for(int i = 0; i < 3; i++)
    data.Add(new Student() {Id=i, Name= $"Student {i}"});
ccb.EditValueType = EditValueTypeCollection.CSV; // It is default value
ccb.DataSource = new BindingSource(data, null);
ccb.ValueMember = "Id";
ccb.DisplayMember = "Name";
ccb.AllowMultiSelect = true;
ccb.EditValueChanged += Ccb_EditValueChanged;
//ccb.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton());
//ccb.ButtonClick += Ccb_ButtonClick;
//ccb.Popup += Ccb_Popup;
gridView1.Columns["Name"].ColumnEdit = ccb;  // I have changed it from "ID" column to "Name" 

If you assign it to the ID column then it will then it expect integer value in cell so raise same error as you are getting after doing selection in the editor.