title: VB.net WPF Dynamic datagrid
body: <p>I have a routine that query an access database and then populate the data into a datagrid.</p>
  
  <p>This is what I currently have:</p>
  
  <pre><code>sql = "SELECT CCC1, CCC2, CCC3, CCC4, CCC5, CCC6, CCC7, CCC8, CCC9, CCC10, CCC11, CCC12, CCC13, CCC14, CCC15, CCC16, CCC17, CCC18, CCC19, CCC20 FROM CablesT " &amp;
             "WHERE (CableID = " &amp; CableIDTextBox.Text &amp; ")"
  da = New OleDbDataAdapter(sql, Con)
  
  ds.Tables.Clear() 'this is important to clear the table
  da.Fill(ds, "DisplaySpecificCable")
  WaterfallchartWindow.CableValuesDataGrid.ItemsSource = ds.Tables("DisplaySpecificCable").DefaultView
  </code></pre>
  
  <p>My XAML looks like this:</p>
  
  <pre><code>  &lt;DataGrid x:Name="CableValuesDataGrid" HorizontalAlignment="Left" Height="75" Margin="380,35,0,0" VerticalAlignment="Top" Width="1305" MinColumnWidth="20" CanUserReorderColumns="True" EnableColumnVirtualization="False" ColumnWidth="60" AlternatingRowBackground="Beige" VerticalGridLinesBrush="LightGray"  HorizontalGridLinesBrush="LightGray" AutoGenerateColumns="False"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Header="Parameters"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="1mm²" Binding="{Binding CCC1}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="1.5mm²" Binding="{Binding CCC2}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="2.5mm²" Binding="{Binding CCC3}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="4mm²" Binding="{Binding CCC4}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="6mm²" Binding="{Binding CCC5}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="10mm²" Binding="{Binding CCC6}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="16mm²" Binding="{Binding CCC7}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="25mm²" Binding="{Binding CCC8}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="35mm²" Binding="{Binding CCC9}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="50mm²" Binding="{Binding CCC10}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="70mm²" Binding="{Binding CCC11}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="95mm²" Binding="{Binding CCC12}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="120mm²" Binding="{Binding CCC13}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="150mm²" Binding="{Binding CCC14}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="185mm²" Binding="{Binding CCC15}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="240mm²" Binding="{Binding CCC16}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="300mm²" Binding="{Binding CCC17}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="400mm²" Binding="{Binding CCC18}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="500mm²" Binding="{Binding CCC19}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Header="630mm²" Binding="{Binding CCC20}"&gt;&lt;/DataGridTextColumn&gt;
  
                  &lt;/DataGrid.Columns&gt;
  
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>This will populate the datagrid row starting from the 2nd column onwards which is what I need But I also would like to:</p>
  
  <ol>
  <li><p>At the "Parameter" column, add static text to the rows. I could not figure out a way to do this.</p></li>
  <li><p>Add a second row to the datagrid via the SQL query of another table. Could not figure this out too.</p></li>
  </ol>
  
  <p>Help most appreciated.</p>