/// <summary> /// Applies the filters registered with each /// column in the order of creation in the <see cref="DataGridView.Columns"/> collection. /// </summary> protected virtual void ApplyFilters() { ColumnFilter columnFilter = null; var panels = GetFilterPanels(); foreach (var panel in panels) { columnFilter = panel.ColumnFilter; if (panel.OnApplyFilter()) { if (columnFilter.FilteredImage != null) { panel.FilterButton.Image = columnFilter.FilteredImage; } else if (columnFilter.FilteredImageSource?.Length > 0) { panel.FilterButton.ImageSource = columnFilter.FilteredImageSource; } } else { if (columnFilter.Image != null) { panel.FilterButton.Image = columnFilter.Image; } else if (columnFilter.ImageSource.Length > 0) { panel.FilterButton.ImageSource = columnFilter.ImageSource; } } } }
/// <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(); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } if (disposing) { var column = this.DataGridViewColumn; if (column != null) { column.HeaderCell.Control?.Dispose(); column.HeaderCell.Control = null; column.UserData.FilterPanel = null; } this.ColumnFilter = null; this.DataGridViewColumn = null; } base.Dispose(disposing); }