title: Extracting Specific Columns from a DataTable
body: <p>I have some code in my C# application which extracts data from a SQL database.</p>
  
  <p>This <code>DataTable</code> is used in various places throughout my application, and is displayed in multiple <code>DataGridViews</code>.</p>
  
  <p>However, I want to show only some of the columns in the <code>Datatable</code>, not all of them.  </p>
  
  <p>Also the columns I want to display are different in each of the <code>DataGridViews</code>.</p>
  
  <p>e.g.  </p>
  
  <ul>
  <li>Show Columns 1-3 in DataGridView1</li>
  <li>Show Columns 4-6 in DataGridView2</li>
  <li>Show Columns 7-12 in DataGridView3  </li>
  </ul>
  
  <p>etc</p>
  
  <p>I could of course just write different code to extract the required fields from SQL for each of the <code>DataGridViews</code>, but this doesn't seem like a very concise solution.</p>
  
  <p>It would be better (I think) if I could use the one <code>DataTable</code> extracted from SQL, and apply multiple filters to it in the application for displaying different Columns in each of the <code>DataGridViews</code>.</p>
  
  <p>I looked at using <code>DataView</code> but whilst this has a <code>Sort</code> method, it doesn't seem to have a <code>Filter</code> method</p>
  
  <p>e.g.</p>
  
  <pre><code>DataTable table = GetDateFromSql();
  DataView view = new DataView(table);
  view.Sort = "FieldName";
  </code></pre>
  
  <p>Ideally I'd like to be able to do something like -</p>
  
  <pre><code>view.Filter = "SELECT cola, colB, colC";
  myDataGridView.DataSource = view;
  </code></pre>
  
  <p>I know there is a <code>RowFilter</code> method, but in effect, its the Columns I want to filter.</p>
  
  <p>How can this be done?</p>