示例#1
0
        /// <summary>
        /// Applies the filters registered with each
        /// column in the order of creation in the <see cref="DataGridView.Columns"/> collection.
        /// </summary>
        protected override void ApplyFilters()
        {
            try
            {
                // make all rows visible before applying the filters.
                var dataGrid = this.DataGridViewColumn.DataGridView;
                foreach (var row in dataGrid.Rows)
                {
                    row.Visible = true;
                }

                // apply all the filters.
                base.ApplyFilters();

                FilteredRowCount = dataGrid.Rows.GetRowCount(DataGridViewElementStates.Visible);
                if (ColumnFilter != null)
                {
                    ColumnFilter.OnFiltersApplied(FilteredRowCount);
                }
            }
            finally
            {
                Close();
            }
        }
        /// <summary>
        /// Applies the filters registered with each
        /// column in the order of creation in the <see cref="DataGridView.Columns"/> collection.
        /// </summary>
        protected override void ApplyFilters()
        {
            try
            {
                // make all rows visible before applying the filters.
                var dataGrid = this.DataGridViewColumn.DataGridView;
                foreach (var row in dataGrid.Rows)
                {
                    row.Visible = true;
                }

                // reset Combined where
                dataGrid.UserData.columFiltercombinedWhere = "";

                // apply all the filters.
                base.ApplyFilters();

                // do the actual filtering
                string combinedWhere = dataGrid.UserData.columFiltercombinedWhere;
                if (combinedWhere.Length > 0)
                {
                    var indexes = dataGrid.Rows.AsQueryable().Where(combinedWhere).Select(r => r.Index).ToArray();
                    foreach (var row in dataGrid.Rows)
                    {
                        if (Array.BinarySearch(indexes, row.Index) < 0)
                        {
                            row.Visible = false;
                        }
                    }
                }

                FilteredRowCount = dataGrid.Rows.GetRowCount(DataGridViewElementStates.Visible);
                if (ColumnFilter != null)
                {
                    ColumnFilter.OnFiltersApplied(FilteredRowCount);
                }
            }
            finally
            {
                Close();
            }
        }