title: Limit rows displayed in DataGridView when using DataSource
body: <p>I have a DataTable containing 10000+ rows, resulting from a SQL Server query. The DataTable is used as the DataSource for a DataGridView, like so (simplified code):</p>
  
  <pre><code>MyBindingSource = New BindingSource(MyDataTable, Nothing)
  MyDataGridView.DataSource = MyBindingSource
  </code></pre>
  
  <p>As this takes a looong time to load, I would like to limit the number of rows <strong>displayed</strong> in the DataGridView, somehow.</p>
  
  <p>I can't use <code>TOP</code> in my query, because I need all the data present in the DataTable for filtering later on, without re-setting the DataSource (<code>MyBindingSource.Filter = MyFilter</code>).</p>
  
  <p>Also, I can't use the <code>Filter</code> property for limiting the number of rows, because there's no relevant data in the query result that I can use for this. To get around this, I've thought about adding TSQL's <code>ROW_NUMBER</code> to the query result (<code>MyBindingSource.Filter = "[RowNumberField] &lt; 100"</code>), but this would only work when no other fields are used in the filter.</p>
  
  <p>Any ideas?</p>