我正在显示一些关于案例的信息,这些信息已经存在于DataGrid
.
在我的MS Access
数据库中,所有日期都以一种DateTime
格式存储,如下所示:dd/MM/yyyy。
问题是当DataGrid
程序运行时显示,格式变为MM/dd/yyyy。
让我迷失的是,当我在分配给之前显示相关MessageBox
单元格的内容时,我得到了正确的格式(dd/MM/yyyy)。DataTable
DataGrid
我尝试更改DateTimeMode
但显示相同的格式。
有人有任何提示谁来解决这个问题?我给你下面的代码:
数据表 temp = dt.Clone();
temp = (from nardin in dt.AsEnumerable().Distinct()
where nardin["NUMERO CLIENT"].ToString() == _centerID.ToString()
select nardin).CopyToDataTable();
RemoveDuplicates(temp, "NUMERO DOSSIER");
foreach (DataRow row in temp.Rows)
{
MessageBox.Show(row["DATE INTERVENTION"].ToString()); //this gives me the DateTime format i'd like to display
}
existingCase.ItemsSource = temp.AsDataView(); //once assigned to the DataGrid the DateTime format is not the same as above
实际上 DataGrid 在 xaml 文件中是这样声明的:
<DataGrid SelectionUnit="FullRow" SelectedItem="{Binding SelectedBI, Mode=TwoWay}" AutoGenerateColumns="True" Margin="0,167,12,167" Name="existingBI" Width="588" HorizontalAlignment="Right">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="resultDataGridBI_MouseDoubleClick"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
我将 DataTable 绑定到:existingCase.ItemsSource = temp.AsDataView();
提前,谢谢!