DataGridViewAutoFilter filter box click vs column header click
Posted on 2013-05-21
I have some code in my ColumnHeaderMouseClick event for my datagrid to sort programatically among other things. I am using the DataGridViewAutoFilter.dll for filtering on almost all my datagrid columns, I do not want any of my code in the ColumnHeaderMouseClick to execute if the user was trying to click the little filter arrow. Here would be the psuedo code I do not know how to write.
private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
DataGridViewColumn dc = dataGridView1.Columns[e.ColumnIndex];
dc.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(dc.HeaderCell);
//somehow access the functions in dc, the source code for DataGridViewAutoFilter shows
//a function that can tell if the little filter box was clicked that they call from the
Here is SOME of their code in the dll
// Show the drop-down list if filtering is enabled and the mouse click occurred
// within the drop-down button bounds. Otherwise, if sorting is enabled and the
// click occurred outside the drop-down button bounds, sort by the owning column.
// The mouse coordinates are relative to the cell bounds, so the cell location
// and the scrolling offset are needed to determine the client coordinates.
if (FilteringEnabled &&
e.X + cellBounds.Left - scrollingOffset, e.Y + cellBounds.Top))
// If the current cell is in edit mode, commit the edit.
// Commit and end the cell edit.
// Commit any change to the underlying data source.
BindingSource source =
this.DataGridView.DataSource as BindingSource;
if (source != null)