So I have a code that gets values from my MS Access database and shows it on my DataGrid, something like as follows:
C#
OleDbConnection dbConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=myDB.accdb");
dbConn.Open();
OleDbCommand dbCmd = new OleDbCommand("SELECT * FROM myTable WHERE stockID LIKE 'stockID'", dbConn);
OleDbDataAdapter dbAdap = new OleDbDataAdapter(dbCmd);
dbAdap.Fill(myDataSet, "myDataTable");
myDataGrid.ItemsSource = new DataView(myDataSet.Tables["myDataTable"]);
XAML
<DataGrid Name="myDataGrid"
Margin="5"
ItemsSource="{Binding}"
IsReadOnly="True"
SelectionMode="Single"
SelectionUnit="FullRow"
HeadersVisibility="Column" />
So, myDataGrid
would show all the columns and rows, some of which are of type int
or double
(see image).
I'd like to format each column to reduce the decimal places, and include thousands separators (1,234.56). Any help or reference would be great.
Thanks in advance.
myDataGrid