I am trying to change the header name of the column by binding, and it’s just adding me a new column with the correct data but keeps the original column with the original SQLite column name.
XAML code
<DataGridTextColumn Binding={Binding sReportNo}” Header=“Number”></DataGridTextColumn>
CS code
using (SQLiteConnection conn = new SQLiteConnection(location))
{
SQLiteCommand code = new SQLiteCommand(“SELECT * FROM Reports”, conn);
conn.open();
SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
myDataGrid.ItemsSources = dt.DefaultView;
cmd.Dipose();
conn.close();
}
the best way to handle this i to simply make the AutoGeneratedColumn = "false"
in the xaml and define every column manually.
Plus with this method you can easily make a few improvement on the visual aspect and if you have Date for exemple, display in the format you want to.
However, this may involve that you create a class to load your data and define the ItemsSource to the list of the object created.
If you need more precision ask and i'll make it more clear for you.
Hope it will help you.