示例#1
0
        private void Frm我指派的任务预览_Load(object sender, EventArgs e)
        {
            this.searchLookUpEdit1.Properties.DataSource = EmpService.findAll();
            List <String> empIds   = this.customAppointment.Assignee;
            List <EmpDto> empDtos  = EmpService.findByIds(empIds);
            List <String> empNames = new List <string>();

            foreach (EmpDto empDto in empDtos)
            {
                empNames.Add(empDto.Name);
            }

            this.searchLookUpEdit1.EditValue = string.Join(",", empNames);                                      //  name
            this.searchLookUpEdit1.ToolTip   = string.Join(",", empIds == null ? new List <String>() : empIds); //  id

            var v = this.luValues.Find(b => b.FindText == this.searchLookUpEdit1.Properties.View.FindFilterText);

            if (v == null)
            {
                v                  = new LookUpMultSelectValues();
                v.FindText         = this.searchLookUpEdit1.Properties.View.FindFilterText;
                v.SelectedValues   = new List <string>();
                v.SelectedDisplays = new List <string>();
                this.luValues.Add(v);
            }
        }
示例#2
0
        private void searchLookUpEdit1View_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
        {
            var a = this.searchLookUpEdit1.Properties.View.GetSelectedRows();
            var v = luValues.Find(b => b.FindText == this.searchLookUpEdit1.Properties.View.FindFilterText);

            if (v == null)
            {
                v                  = new LookUpMultSelectValues();
                v.FindText         = this.searchLookUpEdit1.Properties.View.FindFilterText;
                v.SelectedValues   = new List <string>();
                v.SelectedDisplays = new List <string>();
                luValues.Add(v);
            }
            if (a.Length > 0)
            {
                //新增状态时
                if (e.Action == CollectionChangeAction.Add)
                {
                    foreach (int rowHandle in a)
                    {
                        var vv = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "Id").ToString();//id 是 Value Member
                        if (string.IsNullOrEmpty(v.SelectedValues.Find(b => b == vv)))
                        {
                            v.SelectedValues.Add(vv);
                            v.SelectedDisplays.Add(this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "Name").ToString());//name 是 Display Member
                        }
                    }
                }
            }
            //删除状态时
            if (e.Action == CollectionChangeAction.Remove)
            {
                List <string> dels = new List <string>();
                List <string> deld = new List <string>();

                for (int i = 0; i < v.SelectedValues.Count; i++)
                {
                    bool finded = false;
                    foreach (int rowHandle in a)
                    {
                        var vv = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "Id").ToString();   //id 是 Value Member
                        var vn = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "Name").ToString(); //name 是 Display Member
                        if (v.SelectedValues[i] == vv)
                        {
                            finded = true;
                            break;
                        }
                    }

                    if (!finded)
                    {
                        dels.Add(v.SelectedValues[i]);
                        deld.Add(v.SelectedDisplays[i]);
                    }
                }

                v.SelectedValues.RemoveAll(b => dels.Contains(b));
                v.SelectedDisplays.RemoveAll(b => deld.Contains(b));

                for (int i = 0; i < luValues.Count; i++)
                {
                    var ev = luValues[i];

                    ev.SelectedValues.RemoveAll(b => dels.Contains(b));
                    ev.SelectedDisplays.RemoveAll(b => deld.Contains(b));
                }
            }
        }