
Introduction
I was looking for an easy and flexible grid filtering mechanism to use with new and old applications. I've found no preexisting solutions that fully satisfy my needs. So, I decided to make my own filtering library. The goals I've tried to reach are:
- Easy to integrate: Availability of a "few lines of code" usage to satisfy the needs of rapid integration.
- User Friendly: Nice to look, easy to use.
- Not code pervasive: Using a
DataGridView derivation would constrain people to re-declare their instances. Moreover, this could be in conflict with existing grid derivations.
- Flexible: There are never enough filters in the world!
Using the Code
This is for eager people. The promised "few lines of code" are just one. Add the DgvFilterPopup.dll to your references. Write somewhere a line like this:
DgvFilterManager filterManager = new DgvFilterManager(dataGridView1);
That's all. Your grid is now able to filter the column values. Right-click on the column headers to see a popup with different filtering features, based on the clicked column data type.
Note: Your grid must be data-bound to a DataView, DataTable, or a BindingSource resolving to one of these two.
Class Architecture
The three main classes are exposed in the following diagram:

The DgvFilterManager Class
The DgvFilterManager class doesn't provide a user interface. Its work is to coordinate the interaction between the DataGridView and the visual filtering elements. When you assign a DataGridView to a DgvFilterManager, the latter attaches some handlers to respond to right click on column headers and to perform some custom painting on the grid. When the user right clicks a column header, the DgvFilterManager shows a popup near the column. This popup is a control that serves as a host for other controls, one for each column. Only one of these child controls is visible at a time, based on the clicked column. We have one filter host control and many column filter child controls.
The filter host control must be a derivation of the DgvBaseFilterHost class, while filter controls must be derived from the DgvBaseColumnFilter class. These two classes don't provide any user interface themselves.
As a default, the DgvFilterManager uses a standard host implementation, named DgvFilterHost, and depending on each column type and data type, one of the filter standard implementations (see below): DgvTextBoxColumnFilter, DgvCheckBoxColumnFilter, DgvComboBoxColumnFilter, or DgvDateColumnFilter.
When a DataGridView is attached to the manager, the latter performs the following actions:
- It creates a filter host that is an instance of the
DgvFilterHost class. If you have already provided a filter host, this step is skipped.
- It creates a list of
DgvBaseColumnFilters, one per column, and initializes each element to a specialization of DgvBaseColumnFilter. If AutoCreateFilters is false, this step is skipped.
You can force a specific column filter type for a certain column, intervening in this process through the ColumnFilterAdding event. You can also intervene, after the auto-creation process, accessing the filter instances through one of the two indexers provided by the manager, and replacing them with user-chosen instances.
The DgvBaseFilterHost Class
The purpose of the filter host control is to show a popup near a right-clicked column and to host child column filter controls. When the popup is shown, only the column filter control related to the right-clicked column is visible. DgvBaseFilterHost is a derivation of UserControl, and provides functionalities to cooperate with DgvFilterManager.
Note: This class is intended as an abstract class. However, declaring it as abstract would generate errors within the designer when designing derived classes.
In your derivation, you have to provide a host area (such as a panel) and override the FilterClientArea to return it. Also, create visual elements for remove filter, remove all filters, apply filter, and use the DgvFilterManager methods ActivateFilter and ActivateAllFilters to make them alive.
The DgvBaseColumnFilter Class
The purpose of a column filter control is to contain visual elements, allowing the end user to construct a filter. When inheriting from it, you can work just like creating any other user control. This class is a derivation of UserControl, and provides functionalities to cooperate with DgvFilterManager.
Note: This class is intended as an abstract class. However, declaring it as abstract would generate errors within the designer when designing derived classes.
You should override OnFilterExpressionBuilding to provide a filter expression construction logic and to set the values of the FilterExpression and FilterCaption properties.
Standard Implementations

The DgvFilterHost Class

This is the standard implementation of DgvBaseFilterHost. This class does nothing special. Most of the logic is in its base class. It just contains visual elements such as buttons and graphics, and a panel acting as the client area for child column filter controls.
The DgvTextBoxColumnFilter Class

This is one of the DgvBaseColumnFilter standard implementations. It's composed of a combobox containing a list of operators and a textbox in which to type the value of the filter. This column filter is used by default with DataGridViewTextBoxColumns, except when the bound data type is DateTime. The list of available operators is different between string types and numeric types.
The DgvTextBoxColumnFilter Class

A standard implementation for the filtering of checkbox columns. The only available operators are the equal and the general null and not null operators.
The DgvDateColumnFilter Class

A standard implementation for the filtering of date columns.
The DgvComboBoxColumnFilter Class

A standard implementation for the filtering of combobox columns. By default, on textbox columns, the filter manager uses DgvTextBoxColumnFilter instances. However, you can force an instance of DgvComboBoxColumnFilter on such columns. In this case, the DgvComboBoxColumnFilter instance automatically creates a distinct list of values from the column data. You should do an explicit call to the RefreshValues() method when the underlying data changes.
Customizing
If "one line usage" is not sufficient for your needs, you can control the process of adding and showing filters in different ways.
Using a DgvComboBoxColumnFilter for Non-Combobox Columns
Use one of the manager indexers to access the filter, and assign it an instance of the DgvComboBoxColumnFilter class.
DgvFilterManager fm = new DgvFilterManager(dataGridView1);
fm["CustomerID"] = new DgvComboBoxColumnFilter();
Using Events
ColumnFilterAdding
Using this manager event, you may force your preferred filter before the manager creates the predefined filter. The event is raised for each column in the grid when you set the DataGridView property.
...
DgvFilterManager fm = new DgvFilterManager();
fm.ColumnFilterAdding += new ColumnFilterEventHandler(fm_ColumnFilterAdding);
fm.DataGridView = dataGridView1;
...
void fm_ColumnFilterAdding(object sender, ColumnFilterEventArgs e) {
if (e.Column.Name == "CustomerID") {
e.ColumnFilter = new DgvComboBoxColumnFilter();
}
}
PopupShowing
This manager event allows you to customize the filter host position when popped up.
...
DgvFilterManager fm = new DgvFilterManager();
fm.DataGridView = dataGridView1;
fm.PopupShowing += new ColumnFilterEventHandler(fm_PopupShowing);
...
void fm_PopupShowing(object sender, ColumnFilterEventArgs e) {
DgvFilterManager fm = ((DgvFilterManager)sender);
Rectangle HeaderRectangle =
fm.DataGridView.GetCellDisplayRectangle(e.Column.Index,-1,true);
fm.FilterHost.Popup.Show(fm.DataGridView, HeaderRectangle.Left,
HeaderRectangle.Bottom);
e.Handled = true;
}
FilterExpressionBuilding

Using the DgvBaseColumnFilter event, you can customize the filter expression building process. In the following code example, we add new operators and then manage them in the event handler. The FilterExpression and FilterCaption properties will be used by the manager to build the whole filter and to set the column caption.
...
DgvDateColumnFilter OrderDate;
...
DgvFilterManager fm = new DgvFilterManager(dataGridView1);
fm.DataGridView = dataGridView1;
OrderDate = ((DgvDateColumnFilter)fm["OrderDate"]);
OrderDate.ComboBoxOperator.Items.Insert(0, "This year");
OrderDate.ComboBoxOperator.Items.Insert(1, "1 year ago");
OrderDate.ComboBoxOperator.Items.Insert(2, "2 years ago");
OrderDate.FilterExpressionBuilding +=
new CancelEventHandler(OrderDate_FilterExpressionBuilding);
...
void OrderDate_FilterExpressionBuilding(object sender, CancelEventArgs e) {
int index = OrderDate.ComboBoxOperator.SelectedIndex;
if (index < 3) {
int year = (DateTime.Today.Year - index);
OrderDate.FilterExpression = "(OrderDate>='" + year.ToString() + "-1-1' "
+ "AND OrderDate<='" + year.ToString() + "-12-31') ";
OrderDate.FilterCaption = OrderDate.OriginalDataGridViewColumnHeaderText
+ "\n = year " + year.ToString();
e.Cancel = true;
}
}
Subclassing
A more powerful way to customize your filters is through subclassing. You should think of the proposed standard implementations of DgvBaseFilterHost and DgvBaseColumnFilter as just some possible implementations.
Creating Your Own Host

As said above, derive from DgvBaseFilterHost and provide some visual elements. Add a container within your control to host the child filter controls, and return it by an override of the FilterClientArea property. The base class provides the necessary logic to cooperate with the manager, and provides some facilities helping to position the child filter controls and to adjust the host size. Another facility simplifies the creation of transparent skinned hosts, thanks to the method BitmapToRegion I've found in a very nice article by John O'Byrne.
Note: A skinned host must be constrained to a fixed size. Be sure to inhibit the resize logic by overriding the DoAutoFit method. Also, keep in mind this limitation when designing your own host and your filters.
DgvFilterManager fm = new DgvFilterManager();
fm.FilterHost = new CustomizedFilterHost();
fm.DataGridView = dataGridView1;
Creating Your Own Column Filters

Creating new column filters is simple. Derive from DgvBaseColumnFilter and add your visual elements. Override OnFilterExpressionBuilding to provide filter building logic and, using DataView.RowFilter rules, assign a value to the FilterExpression property and a title to the FilterCaption property.
Remember that the filter is applied when the user clicks on the OK button of the host. However, you can obtain an immediate filter application doing a call to the RebuildFilter method of the filter manager.
New Filters
To satisfy some requests, in the 1.1.0.0 update, I've introduced three new filter implementations:

The DgvMonthYearColumnFilter Class

This filter allows the user to select a month and a year. By setting the YearMin and YearMax properties, you can control the shown years range. Month names default to English, but you may provide culture-specific names by once setting the value of the static property MonthCsvList with a comma separated list of month names.
The DgvNumRangeColumnFilter Class

Use this filter to allow the user to specify a range filter on numeric columns.
The DgvDateRangeColumnFilter Class

Use this filter to allow the user to specify a range filter on date columns.
Conclusions
In this article, I've exposed the class architecture and common usage scenarios. This conceptual overview, I hope, will help you understand how it works. For detailed explanations and references, you can see the attached documentation.
Note: To those interested in documenting their works, I've used these materials:
History
- 1.1.0.0 (19 Mar 2009)
- Added three new embedded filters:
DgvDateRangeColumnFilter, DgvMonthYearColumnFilter, and DgvNumRangeColumnFilter.
- It's now possible to dynamically change the
DataSource.
- 1.0.0.1 (04 Mar 2009)
- Fix: Filters are now applied when the grid is bound to a
BindingSource which uses a DataSet as the first source.
- 1.0.0.0 (01 Mar 2009)
|
|
 |
 | Width of ComboBox GlimmerMan | 6:31 16 Mar '10 |
|
 |
I tried your example for adding "This year", "1 year ago" and "2 years ago" sample which works fine other than the text descriptions are not easily viewed since the ComboBox does not adjust for the width of the newly added items.
Any suggestions on how to make these items fully visible?
Thanks again for this excellent filter component!!!
Here is the code I mentioned above
OrderDate = (CType(filterManager("OrderDate"), DgvDateColumnFilter))
OrderDate.ComboBoxOperator.Items.Insert(0, "This year") OrderDate.ComboBoxOperator.Items.Insert(1, "1 year ago") OrderDate.ComboBoxOperator.Items.Insert(2, "2 years ago")
AddHandler OrderDate.FilterExpressionBuilding, AddressOf OrderDate_FilterExpressionBuilding ... Private Sub OrderDate_FilterExpressionBuilding(ByVal sender As Object, ByVal e As CancelEventArgs)
Dim index As Integer = OrderDate.ComboBoxOperator.SelectedIndex
If index < 3 Then Dim year As Integer = (DateTime.Today.Year - index) OrderDate.FilterExpression = _ "(OrderDate>='" & year.ToString() & "-1-1' " & "AND OrderDate<='" & year.ToString() & "-12-31') "
OrderDate.FilterCaption = _ OrderDate.OriginalDataGridViewColumnHeaderText + Constants.vbLf & " = year " & year.ToString()
e.Cancel = True
End If
End Sub
Kevin S. Gallagher Programming is an art form that fights back
|
|
|
|
 |
 | TextBox in DataGridView Header omidt20 | 20:24 14 Feb '10 |
|
 |
hello my friend. how can i put textBox for each column in dataGridView header. tnk
|
|
|
|
 |
 | Thank you. pdubz | 18:05 8 Feb '10 |
|
 |
This is great; and I think it's tremendous that you went through all the effort to share it. You should include fixes (like the spaces one someone discovered earlier) as well as encourage uploads of custom implementations someplace. I'll need to be implementing Excel Autofilter-like functionality (multiple item selection, etc) and would be happy to contribute, but can't imagine someone hasn't already extended it to accomplish this.
Anyways, thanks for sharing; great work.
|
|
|
|
 |
 | Thank you tigergudu | 10:56 7 Feb '10 |
|
 |
Grid filtration easy to use (with one row in code!!!) in 5 minutes it is great
I love it.
|
|
|
|
 |
 | Grid context menu compatibility Joao Paulo Figueira | 3:19 7 Feb '10 |
|
 |
As I painfully found out, setting the grid's ContextMenuStrip property will disable the filter popup. To make both work, you have to show the grid's context menu from your own CellMouseClick handler. Here's a sample that I have used:
private void gridQuery_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if(e.Button == MouseButtons.Right && e.RowIndex != -1 && e.ColumnIndex > -1) { Rectangle rect = gridQuery.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
gridQuery.ClearSelection(); gridQuery[e.ColumnIndex, e.RowIndex].Selected = true; menuGrid.Show(gridQuery, rect.X + e.X, rect.Y + e.Y); } }
|
|
|
|
 |
 | Escape column names Joao Paulo Figueira | 12:23 4 Feb '10 |
|
 |
Great tool! I will use it on my own code.
Meanwhile, I found one issue that is not covered in the published code: the filter fails on columns with embedded spaces, like "Ship Via". In this case, the DataView filter expression requires that you enclose the column name in square brackets like "[Ship Via]". This requires a very simple change in the OnFilterExpressionBuilding override method. Something like:
ResultFilterExpression = "[" + this.DataGridViewColumn.DataPropertyName + "] LIKE '%" + FilterValue + "%'";
|
|
|
|
 |
 | ListBox pmtolk | 9:35 1 Feb '10 |
|
 |
//an addition to the DataGridView Filter Popup for adding a listbox in order to get multiple selected items which are OR'ed together //filterManager["CustomerID"] = new DgvListBoxFilter(); //written by Philip Tolk if you have any questions you can email me at pmtolk@gmail.com
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms;
namespace DgvFilterPopup {
/// <summary> /// A standard <i>column filter</i> implementation for ListBox columns. /// </summary> /// <remarks> /// If the <b>DataGridView</b> column to which this <i>column filter</i> is applied /// is not a ListBox column, it automatically creates a distinct list of values from the bound <b>DataView</b> column. /// If the DataView changes, you should do an explicit call to <see cref="DgvListBoxFilter.RefreshValues"/> method. /// </remarks> public partial class DgvListBoxFilter : DgvBaseColumnFilter { public DgvListBoxFilter() { InitializeComponent(); listBox1.SelectedValueChanged += new EventHandler(onFilterChanged); }
/// <summary> /// Perform filter initialitazion and raises the FilterInitializing event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param> /// <remarks> /// When this <i>column filter</i> control is added to the <i>column filters</i> array of the <i>filter manager</i>, /// the latter calls the <see cref="DgvBaseColumnFilter.Init"/> method which, in turn, calls this method. /// You can ovverride this method to provide initialization code or you can create an event handler and /// set the <i>Cancel</i> property of event argument to true, to skip standard initialization. /// </remarks> protected override void OnFilterInitializing(object sender, CancelEventArgs e) { base.OnFilterInitializing(sender, e); if (e.Cancel) return; listBox1.SelectedIndex = -1; listBox1.ValueMember = this.DataGridViewColumn.DataPropertyName; listBox1.DisplayMember = this.DataGridViewColumn.DataPropertyName; RefreshValues(); }
/// <summary> /// For non-combobox columns, refreshes the list of the <b>DataView</b> values in the column. /// </summary> public void RefreshValues() { if (!(this.DataGridViewColumn is DataGridViewComboBoxColumn)) { DataTable DistinctDataTable = this.BoundDataView.ToTable(true, new string[] { this.DataGridViewColumn.DataPropertyName }); DistinctDataTable.DefaultView.Sort = this.DataGridViewColumn.DataPropertyName; listBox1.DataSource = DistinctDataTable; } }
/// <summary> /// Builds the filter expression and raises the FilterExpressionBuilding event /// </summary> /// <param name="sender">The event source.</param> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param> /// <remarks> /// Override <b>OnFilterExpressionBuilding</b> to provide a filter expression construction /// logic and to set the values of the <see cref="DgvBaseColumnFilter.FilterExpression"/> and <see cref="DgvBaseColumnFilter.FilterCaption"/> properties. /// The <see cref="DgvFilterManager"/> will use these properties in constructing the whole filter expression and to change the header text of the filtered column. /// Otherwise, you can create an event handler and set the <i>Cancel</i> property of event argument to true, to skip standard filter expression building logic. /// </remarks> protected override void OnFilterExpressionBuilding(object sender, CancelEventArgs e) { base.OnFilterExpressionBuilding(sender, e); if (e.Cancel) { FilterManager.RebuildFilter(); return; }
string ResultFilterExpression = ""; string ResultFilterCaption = OriginalDataGridViewColumnHeaderText;
ResultFilterExpression = "("; for (int i = 0; i < listBox1.SelectedItems.Count; i++) { DataRowView FilterValue =(DataRowView) listBox1.SelectedItems[i]; string EscapedFilterValue = StringEscape(FilterValue.Row.ItemArray[0].ToString()); if (EscapedFilterValue != "") {
ResultFilterExpression += this.DataGridViewColumn.DataPropertyName + " ='" + EscapedFilterValue + "'"; ResultFilterCaption = "\n=ListBox filter"; } if (i < listBox1.SelectedItems.Count - 1) { ResultFilterExpression += " OR "; } } ResultFilterExpression += ")"; if (ResultFilterExpression != "") { FilterExpression = ResultFilterExpression; FilterCaption = ResultFilterCaption; FilterManager.RebuildFilter(); } }
private void onFilterChanged(object sender, EventArgs e) { if (!FilterApplySoon || !this.Visible) return; Active = true; FilterExpressionBuild();
} } }
|
|
|
|
 |
 | Great work, perfect! otech | 15:01 23 Jan '10 |
|
 |
Very nice job on this sorely needed component - its a must for every dgv.
|
|
|
|
 |
 | How to correct a bug where a filter is not become applicable when select statement contains quoted names Tushar Bhatt | 23:08 19 Jan '10 |
|
 |
Hello,
Very nice control, and almost indispensable, however I am facing following problem.
1. When I populate a dgv with a SQL statement like
SELECT t_name 'Name', t_address 'Address', t_city from pary;
and if I try to filter the content on 'Name' or 'Address' fields, filter will not work. However, filter will work on t_city.
As it can be judged from the above that if a quoted name is given to a field, filter will not work. Filter will work only on actual table field.
Can somebody suggest, how can I rectify the bug or correct the limitation?
Tushar Bhatt
|
|
|
|
 |
 | DgvDateRangeColumnFilter not work in MDI hiephib | 21:21 19 Jan '10 |
|
 |
thank you,Vincenzo Rossi
I try using your control,but i try this with DgvDateRangeColumnFilter and MDIParent, this not work,hepl me,thank you very mach
|
|
|
|
 |
 | help me hiephib | 21:21 19 Jan '10 |
|
 |
thank you,Vincenzo Rossi
I try using your control,but i try this with DgvDateRangeColumnFilter and MDIParent, this not work,hepl me,thank you very mach
|
|
|
|
 |
 | Perferct article Stanciu Vlad | 5:55 15 Jan '10 |
|
 |
Your article was covering exactly what I was looking for. Thank you.
I have no smart signature yet...
|
|
|
|
 |
 | How to persist filter expressions Ed Bouras | 3:45 7 Jan '10 |
|
 |
Hi Vincenzo. Thank you very much for suc a geat product. I woudl like to integrte it into a user control grid that can persist various settings per data source including filter expressions, and then re-apply them one the source is set gain. Can you provide a quick explanation as to best practice per your classes?
I looped through the columns and was able to access the expressions with something like this: manager.Item(column.Name).FilterExpression, thus allowing me to create a dictionary of column name/expression. This appears to work fine, but when I try to set the filter expressions things go very awry. Using the same loop code and just assigning a value to FilterExpression and then activating that filter works, but the column headers show a blank white box (I am using your classes straight out of the "box"). When I right click on the header it shows no expression set in the UI host even though the filter is activated. Also, it seems to "remember" filters that were shut off - so I turn 3 on, turn 2 off (both actions through UI) and it persists 3!?!
I must be skipping a critical step, so could you provide a little guidance for this situation? Anything you could do woudl be a big help.
|
|
|
|
 |
|
 |
i had same problem and solved this way:
bool[] activeFilter = new bool[NUM_COL]; string[] activeFilterExpression = new string[NUM_COL]; string[] activeFilterCaption = new string[NUM_COL]; for (int i = 0 ; i < NUM_COL ; i++) { activeFilter[i] = dvgFilter[i].Active; activeFilterExpression[i] = dvgFilter[i].FilterExpression; activeFilterCaption[i] = dvgFilter[i].FilterCaption; } dvgFilter.ActivateAllFilters(false); ReloadGridView();
for (int j = 0; j < NUM_COL; j++) { dvgFilter[j].Active = activeFilter[j]; dvgFilter[j].FilterExpression = activeFilterExpression[j]; dvgFilter[j].FilterCaption = activeFilterCaption[j]; } dvgFilter.RebuildFilter();
Hope this help.
|
|
|
|
 |
 | The DgvTextBoxColumnFilter, how to fox75 | 9:36 30 Dec '09 |
|
 |
Hi,
where do I have to change to make that: Question 1: after rightclick that the textBoxValue and not comboBoxOperator is active ? (in fact I would like that after right click I can directly write the text on textBoxValue)
Question 2: After inserting something on the textBoxValue I would like to press "enter" as alternative to "OK", where do I have to change ?
Thanks a lot to whill help me (I understand also italian and french)
|
|
|
|
 |
 | How can you dispose of or turn off the DgvFilterManager temporarily after you create the original instance DB23 | 18:27 8 Dec '09 |
|
 |
I want to be able to toggle the filtermanager on and off via a button so that I can show a custom contextmenustrip when a column header is right-clicked on and the filter is in "off-mode". Or be able to handle the "e.Button = Windows.Forms.MouseButtons.Right" event so that the dgvPopup doesn't display if I specify my criteria. Currently (default behavior) is that if the column header is left clicked it sorts the column A-Z, Z-A, if right-clicked it displays the dgvpopup. I want to also be able to right-click on the dgvfiltermanager if it is turned off and remove columns, reorder, etc. via a contextmenustrip.
I think this is a wonderful component!! Time saver for sure!
|
|
|
|
 |
|
 |
Hi DB23, your request is very reasonable. Ok, we need something allowing the good developer to specify if the manager is enabled or disabled. So, with great fantasy, we could add a boolean property to the manager and call it: Enabled. After that we have to turn off the handling of the right click on the grid. We could attach/detach the handler, but I get bored and a faster way is to change the condition in the handler.
public class DgvFilterManager { ... private bool mEnabled = true;
public bool Enabled { get { return mEnabled; } set { mEnabled = value; } } ... protected virtual void mDataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (mEnabled && e.Button == MouseButtons.Right && e.RowIndex == -1 && e.ColumnIndex > -1) { ShowPopup(e.ColumnIndex); } }
}
Have fun Vin
|
|
|
|
 |
|
 |
Hi againg, columns reordering is a feature of the DataGridView. The user can drag and drop the columns to change the order. About hiding/showing, take a look to this article: A DataGridView Column Show/Hide Popup[^]
Vin
|
|
|
|
 |
 | A must have... GlimmerMan | 5:30 2 Dec '09 |
|
 |
I have seen a lot of controls, components and code for the DataGridView but this popup filter takes the cake. It was saved me countless hours on several projects. I really like how easy it is to save and restore filters from one session to another. Thanks again for sharing.
PS It would be nice if Microsoft had this as standard issue in the Framework.
Kevin S. Gallagher Programming is an art form that fights back
|
|
|
|
 |
|
|
 |
 | Truly Excellent work CreF | 6:32 12 Nov '09 |
|
 |
Hi Vincenzo, great and cool work
My vote of 5 has just been sent.
Congratulazioni from an Italian developer living in Italian part of Switzerland...
That's what I was searching for the application I develop for internal use in the company I work for.
A very little question: in some cases I work with huge datasets (maybe more than 10'000 records, so what about performances? I have to admit that I just discovered your component and I still haven't tested it, I just red your article...
Salutissimi Francesco
the CreF
|
|
|
|
 |
|
 |
Ciao Francesco, thank you. The performances are not directly affected by the filter library because it uses just the DataView filtering capabilities. I've tested it in a real application with about 3000 records and 10 columns and it seems to work fine. When a DataGridView has to show many many records, Microsoft suggests to use the virtual mode [^]. I didn't test that technique but at a rapid look it seems not using databinding nor dataviews so in that case the filter library is not appliable. Try...and let's hope everything will be ok. Vin
|
|
|
|
 |
 | Great utility - thank you ger0nim0 | 3:50 2 Nov '09 |
|
 |
Thank you for this library - very useful: it has saved me money or hours of development!
One feature I need (among others) is an event that fires after the (re)building of the filter expression. It would be nice if you added it to the original source.
In any case I modified the code (so easy because it is very well documented and designed) to add such an event.
In DgvFilterManager.cs add the following Event:
public event CancelEventHandler FilterPostExpressionBuilding;
and modify rebuildFilter() with this:
try
{ if (mBindingSource != null) { if (mBindingSource.Filter != Filter) { mBindingSource.Filter = Filter; if (FilterPostExpressionBuilding != null) FilterPostExpressionBuilding(this, new CancelEventArgs(false)); } } else
{ if (mBoundDataView.RowFilter != Filter) { mBoundDataView.RowFilter = Filter; if (FilterPostExpressionBuilding != null) FilterPostExpressionBuilding(this, new CancelEventArgs(false)); } } }
You may now add the event to your Filter manager and know that the filter has been applied and the datagridview refreshed.
Grazie mille
Claudio
|
|
|
|
 |
 | On the Outlook Grid Control this Filter Popup not working sujit9923 | 1:01 30 Oct '09 |
|
 |
I am using a Outlook Grid there is no use of this filter....... Please give me the solution
|
|
|
|
 |
 | Focus pstsp911 | 19:24 27 Oct '09 |
|
 |
How to force textBoxValue to have initially focus/keyboard input, instead of comboBoxIOperator?
|
|
|
|
 |
|
|
Last Updated 20 Mar 2009 |
Advertise |
Privacy |
Terms of Use |
Copyright ©
CodeProject, 1999-2010