应用场景
当从ColumnEdit(如SearchLookUpEdit)中选取一条记录后,ColumnEdit的数据源不再出现这条记录。效果图如下
选择前
选择一条记录后,上一条记录不再显示。
此处是SearchLookUpEdit,所以会有额外的处理,同样适用于LookUpEdit
//不显示下拉按钮和禁止下拉 replaceLueStaff.Buttons.Clear(); replaceLueStaff.ShowDropDown = DevExpress.XtraEditors.Controls.ShowDropDown.Never; replaceLueStaff.Click += new EventHandler(replaceLueStaff_Click); void replaceLueStaff_Click(object sender, EventArgs e) { //获取选中的ColumnEdit SearchLookUpEdit lue = sender as SearchLookUpEdit; //linq实现 not in 筛选 //gvActor.DataSource为当前gridview,m_dtStaffAll为控件数据源 var selectedIds = ((DataView)(gvActor.DataSource)).OfType<DataRowView>().Select(x => x["STAFF_ID"].ToString()); var query = from p in m_dtStaffAll.AsEnumerable() where !(from x in selectedIds select x).Contains(p["STAFF_ID"].ToString()) select p; lue.Properties.DataSource = query.AsDataView(); lue.ShowPopup(); }