Last Updated: February 25, 2016
·
3.034K
· hjwu

DevExpress LookupEdit RowFilter

There are two method to do this.

  • Change DataSource
DataTable oldDataTable = myLookUpEdit.Properties.DataSource as DataTable;
DataRow[] myDataRows = oldDatatable.Select(filter);
DataTable newDataTable = oldDataTable.Clone();

foreach (DataRow dr in myDataRows) newDataTable.ImportRow(dr); ;
myLookupEdit.Properties.DataSource = newDataTable;
  • Use GridLookUpEdit
myGridLookUpEdit.Properties.View.CustomRowFilter += (s, e) =>
{
  DevExpress.XtraGrid.Views.Grid.GridView myView = 
  s as DevExpress.XtraGrid.Views.Grid.GridView;

  DataView myDataView =  myView.DataSource as DataView;

  if (myDataView[e.ListSourceRow][index] holds some condition)
  {
      e.Visible = false; //hidden some row
      e.Handled = true;
  }
};