windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemlookupedit-e21841db.md
Gets or sets whether you can bind the LookUpEdit.EditValue property to a read-only property of a collection type. With this option enabled, the editor calls the collection’s methods to add and remove items.
Namespace : DevExpress.XtraEditors.Repository
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DefaultValue(DefaultBoolean.Default)]
[DXCategory("Data")]
public virtual DefaultBoolean EnableEditValueCollectionEditing { get; set; }
<DXCategory("Data")>
<DefaultValue(DefaultBoolean.Default)>
Public Overridable Property EnableEditValueCollectionEditing As DefaultBoolean
| Type | Default | Description |
|---|---|---|
| DefaultBoolean | Default |
True to use the collection’s methods to add and remove items.
False to create a new collection each time the EditValue property is changed.
Default is True if the EditValue property is bound to a read-only property of a collection type.
|
Available values:
| Name | Description | Return Value |
|---|---|---|
| True |
The value is true.
|
0
| | False |
The value is false.
|
1
| | Default |
The value is specified by a global option or a higher-level object.
|
2
|
In ValueList multiple selection mode, the LookUpEdit.EditValue property contains a List<object> object with selected items. The EnableEditValueCollectionEditing property allows you to bind the EditValue property to a read-only property of a collection type (for example, a HashSet<T>).
public partial class Form1 : Form {
Employee person;
List<Department> departments;
public Form1() {
InitializeComponent();
person = new Employee {
ID = 1,
FullName = "John Smith",
};
departments = new List<Department> {
new Department() { ID = 1, Name = "IT Department" },
new Department() { ID = 2, Name = "Sales" },
new Department() { ID = 3, Name = "Management" },
new Department() { ID = 4, Name = "Support" },
new Department() { ID = 5, Name = "Human Resources" },
new Department() { ID = 6, Name = "Engineering" },
new Department() { ID = 7, Name = "Shipping" },
};
// Populates binding sources with data.
employeeBindingSource.DataSource = person;
departmentBindingSource.DataSource = departments;
leDepartments.Properties.DataSource = departmentBindingSource;
leDepartments.Properties.ValueMember = "ID";
leDepartments.Properties.DisplayMember = "Name";
leDepartments.Properties.EditValueType = DevExpress.XtraEditors.Repository.LookUpEditValueType.ValueList;
// Binds the editor's EditValue property to the Employee.Departments property.
leDepartments.DataBindings.Add(new Binding("EditValue", employeeBindingSource, "Departments", true, DataSourceUpdateMode.OnPropertyChanged));
}
}
public class Employee {
public Employee() {
Departments = new HashSet<int>();
}
public int ID { get; set; }
public string FullName { get; set; }
// Creates a read-only property of the HashSet<T> type.
public HashSet<int> Departments { get; private set; }
}
public class Department {
public int ID { get; set; }
public string Name { get; set; }
}
Partial Public Class Form1
Inherits Form
Private person As Employee
Private departments As List(Of Department)
Public Sub New()
InitializeComponent()
person = New Employee With { .ID = 1, .FullName = "John Smith" }
departments = New List(Of Department) From {
New Department() With { .ID = 1, .Name = "IT Department" },
New Department() With { .ID = 2, .Name = "Sales" },
New Department() With { .ID = 3, .Name = "Management" },
New Department() With { .ID = 4, .Name = "Support" },
New Department() With { .ID = 5, .Name = "Human Resources" },
New Department() With { .ID = 6, .Name = "Engineering" },
New Department() With { .ID = 7, .Name = "Shipping" }
}
' Populates binding sources with data.
employeeBindingSource.DataSource = person
departmentBindingSource.DataSource = departments
leDepartments.Properties.DataSource = departmentBindingSource
leDepartments.Properties.ValueMember = "ID"
leDepartments.Properties.DisplayMember = "Name"
leDepartments.Properties.EditValueType = DevExpress.XtraEditors.Repository.LookUpEditValueType.ValueList
' Binds the editor's EditValue property to the Employee.Departments property.
leDepartments.DataBindings.Add(New Binding("EditValue", employeeBindingSource, "Departments", True, DataSourceUpdateMode.OnPropertyChanged))
End Sub
Public Class Employee
Public Sub New()
Departments = New HashSet(Of Integer)()
End Sub
Public Property ID() As Integer
Public Property FullName() As String
' Creates a read-only property of the HashSet<T> type.
Private privateDepartments As HashSet(Of Integer)
Public Property Departments() As HashSet(Of Integer)
Get
Return privateDepartments
End Get
Private Set(ByVal value As HashSet(Of Integer))
privateDepartments = value
End Set
End Property
End Class
Public Class Department
Public Property ID() As Integer
Public Property Name() As String
End Class
End Class
Refer to the following help topic for more information: LookUpEdit - Enable Multiple Item Selection.
See Also
RepositoryItemLookUpEdit Class