title: How to remove last column datatable c#
body: <p><strong>EDIT</strong></p>
  
  <p>I have tried to set the AutoGeneratColumns property to false as suggested in:
  <a href="https://stackoverflow.com/questions/20770701/how-to-remove-extra-column-datagrid">How to remove extra column Datagrid</a>.</p>
  
  <p>However, all my columns disappear if I do that.</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>I have a data table with program generated columns and rows. However, I get an extra column to the right of my generated columns. What should I write to make it disappear? </p>
  
  <p>The xaml:</p>
  
  <pre><code>&lt;DataGrid CanUserAddRows="False"&gt;
              &lt;DataGrid.ItemsSource&gt;
                  &lt;MultiBinding Converter="{StaticResource MatrixToDataViewConverter}"&gt;
                      &lt;Binding Path="ColumnHeaders" ElementName="Results"/&gt;
                      &lt;Binding Path="RowHeaders" ElementName="Results"/&gt;
                      &lt;Binding Path="Values" ElementName="Results"/&gt;
                  &lt;/MultiBinding&gt;
          &lt;/DataGrid.ItemsSource&gt;
        &lt;/DataGrid&gt;
  </code></pre>
  
  <p>the convert method</p>
  
  <pre><code>public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
              {
                  var myDataTable = new DataTable();
  
                  string[] columns = values[0] as string[];
                  string[] rows = values[1] as string[];
                  double[,] matrix = values[2] as double[,];
  
                  myDataTable.Columns.Add("---"); //Upper left corner
  
                  foreach (string value in columns)
                  {
                      myDataTable.Columns.Add(value);
                  }
  
  
                  foreach (string value in rows)
                  {
                      myDataTable.Rows.Add(value);
                  }
  
                  for (int i = 0; i &lt; matrix.GetLength(0); i++)
                  {
                      int row = System.Convert.ToInt32(matrix[i, 1]) - 1;
                      int column = System.Convert.ToInt32(matrix[i, 0]);
                      myDataTable.Rows[row][column] += matrix[i, 2].ToString() + " to " + matrix[i, 3].ToString() + Environment.NewLine;
                  }
  
                  return myDataTable.DefaultView;
              }
  </code></pre>