title: Filtering a DataGridView per column with filters visible above columns
body: <p>I have a rather specific query -</p>
  
  <p>I want to be able to retrieve data from a database, display it in a DataGridView and allow the user to filter columns by inputting simple filter queries above each column.</p>
  
  <p>For example:-</p>
  
  <pre><code>        | Foo   | Bar                 | Baz |
          ------------------------------------|
  Filters | &gt; 10  | 1/1/1980 - 1/1/2009 | Boo |
          | 12    | 1/3/1995            | Boo |
          | 99    | 5/12/2005           | Boo |
                       etc.
  </code></pre>
  
  <p>The method I thought would best address this problem was to have two DataTables, one which acts as the DataSource for the DataGridView (so I can have the view autogenerate the columns and not have to write a whole bunch of boilerplate to insert rows myself), which itself consists of a single row to hold the filters and the database data below it, and the second holding the database data which can be programmatically appended to the first.</p>
  
  <p>The problem with that solution is that the columns are restricted to the type of the column, for example here Foo is an integer, Bar is a DateTime and Baz is a string. When trying to enter filter text into Foo or Bar the DataGridView throws an error stating that the cell cannot contain text.</p>
  
  <p>Is it possible to have a row containing types utterly divorced from the types of the columns of the rest of the table?</p>
  
  <p>Another solution might be to have textboxes sat above the grid synced with column addition, removal, resizing and user scrolling, however this seems like an enormous amount of work and knowing WinForms I'd probably find out 3 days in that this approach fails spectacularly due to some subtle WinForms limitation.</p>
  
  <p>Solutions which are not possible - using WPF, using a 3rd-party DataGridView (unless, perhaps, an OSS DGV with a commercial usage license).</p>
  
  <p>Currently it seems the best solution might be to import all data into the database datatable as strings (the data below the filters is read-only). That seems quite astoundingly hackish, however.</p>
  
  <p>Am I missing something simple and obvious here? I'm happy to be proven wrong if it gives me some way forward! :-)</p>