當從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(); }