Current filter:
                                You should refresh the page.

                                How to Filter Large List Views via the Auto Filter Row

                                0

                                This example demonstrates how to avoid the display of the entire collection of a List View with a large object count in Windows Forms applications. One of the ways to do this is to use the Auto Filter Row of the XtraGrid used in Windows Forms applications to display List Views.

                                See code in the AutoFilterRowController.cs (AutoFilterRowController.vb) file. For details, refer to the How to: Filter Large List Views via the Auto Filter Row topic in XAF documentation.

                                You must  log in  or  register  to leave comments
                                Select file
                                • AutoFilterRowController.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2012 vol 1.4 - v2012 vol 2.8
                                • v2011 vol 2.5 - v2011 vol 2.14
                                • v2011 vol 1.4 - v2011 vol 1.12
                                • v2010 vol 2.3 - v2010 vol 2.11
                                • v2009 vol 2.4 - v2010 vol 1.12
                                • v8.2.2 - v2009 vol 1.11
                                using System;
                                using System.ComponentModel;
                                using System.Collections.Generic;
                                using System.Diagnostics;
                                using System.Text;
                                
                                using DevExpress.ExpressApp;
                                using DevExpress.ExpressApp.Actions;
                                using DevExpress.Persistent.Base;
                                
                                using DevExpress.XtraGrid.Views.Base;
                                using DevExpress.Data.Filtering;
                                using DevExpress.XtraGrid;
                                
                                namespace HowToFilterLargeListViewsViaAutoFilterRow.Module.Win {
                                   public partial class AutoFilterRowController : ViewController {
                                      public AutoFilterRowController() {
                                         InitializeComponent();
                                         RegisterActions(components);
                                      }
                                      private ListView view;
                                      private ColumnView gridView;
                                      private CriteriaOperator falseCriteria = CriteriaOperator.Parse("1=0");
                                      private void AutoFilterRowController_Activated(object sender, EventArgs e) {
                                         view = (ListView)View;
                                         view.ControlsCreated += new EventHandler(AutoFilterRowController_ControlsCreated);
                                      }
                                      void AutoFilterRowController_ControlsCreated(object sender, EventArgs e) {
                                         GridControl grid = view.Control as GridControl;
                                         gridView = grid.FocusedView as ColumnView;
                                         if (gridView.ActiveFilter.IsEmpty) {
                                            view.CollectionSource.Criteria["FalseCriteria"] = falseCriteria;
                                         }
                                         gridView.ActiveFilter.Changed += new EventHandler(ActiveFilter_Changed);
                                      }
                                      void ActiveFilter_Changed(object sender, EventArgs e) {
                                         if (((ViewFilter)sender).IsEmpty) {
                                            view.CollectionSource.Criteria["FalseCriteria"] = falseCriteria;
                                         }
                                         else {
                                            if (view.CollectionSource.Criteria.ContainsKey("FalseCriteria")) {
                                               view.CollectionSource.Criteria.Remove("FalseCriteria");
                                            }
                                         }
                                      }
                                   }
                                }