title: How to create CSV from select columns in Datagrid?
body: <pre><code> if (!Directory.Exists("C:\\VIES"))
          {
              Directory.CreateDirectory("C:\\VIES");
          }
          dgRecords1.SelectAllCells();
          dgRecords1.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
  
          ApplicationCommands.Copy.Execute(null, dgRecords1);
          dgRecords1.UnselectAllCells();
          String result = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
          try
          {
              StreamWriter sw = new StreamWriter("C:\\VIES\\VIESReport.CSV", false);
              sw.WriteLine(result);
              sw.Close();
              Process.Start("C:\\VIES\\VIESReport.CSV");
          }
  </code></pre>
  
  <p>In this code above, I select all records in the datagrid along with headers and write this to a csv file. What I need to do is that I need only two columns to be in the csv. Is there a way of doing that?</p>