-
Jul 17th, 2024, 03:01 PM
#1
Thread Starter
PowerPoster
[RESOLVED] DevExpress LookUpEdit Multi Select
I am using a DevExpress LookUpEdit in my application and assigning it to be multi-selectable. WHile it works that you can select more than one entry in the list, I am having trouble discovering what was picked. I have a question into DX, it's publicly posted so here is that: My DX Question but I have a feeling they are going to say it's a programming language question and not specific to their controls.
So the question, repeated here, is if I assigned the DataSource of the lookupedit like this:
Code:
public class empTeam
{
public int empDepartmentID { get; set; }
public string empDepartmentDescription { get; set; }
};
//List<empTeam> listOfTeams = new List<empTeam>();
//foreach (dsEmps.EmpTeamDepartmentsRow dr in dtEmps.Rows)
//{
// empTeam item = new empTeam();
// item.empDepartmentDescription = dr.EmpDepartmentDescription;
// item.empDepartmentID = dr.EmpDepartmentID;
// listOfTeams.Add(item);
//}
//lkup.Properties.DataSource = listOfTeams;
how do I get access to what the user chose when I handle the EditValueChanged event? The debug window shows me this:
? lkupTeamDepartment.EditValue
Count = 2
[0]: 12
[1]: 2
Meaning the user chose EmpDepartmentID 12 and 2. Perfect. But I can't figure out what the line(s) of code need to be to access these values. Here are some of my embarassing attempts:
? List<object>lkupTeamDepartment.EditValue
error CS0726: 'lkupTeamDepartment.EditValue' is not a valid format specifier
? new System.Collections.Generic.Mscorlib_CollectionDebugView<object>(lkupTeamDepartment.EditValue).Items[0]
error CS1503: Argument 1: cannot convert from 'object' to 'System.Collections.Generic.ICollection<object>'
? <object>(lkupTeamDepartment.EditValue).Items[0]
error CS1525: Invalid expression term '<'
? (IList<ComboBoxes.ComboBoxes.empTeam>lkupTeamDepartment.EditValue).ToString
error CS0305: Using the generic type 'IList<T>' requires 1 type arguments
I
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
-
Jul 18th, 2024, 07:29 AM
#2
Thread Starter
PowerPoster
Re: DevExpress LookUpEdit Multi Select
DX answered me:
if(lookUpEdit.EditValue is List<object> selectedValues) {
foreach(object value in selectedValues) {
// If ValueMember is an integer field
int intValue = (int)value;
}
}
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|