MySqlCommand cmd = new MySqlCommand(query, conn);
dt.Load(cmd.ExecuteReader());
source.DataSource = dt;
dataGrid1.ItemsSource = source;
在我的数据网格中,我想将DateTime
的列类型更改为String
,我该怎么做?
来源是
System.Windows.Forms.BindingSource source = new System.Windows.Forms.BindingSource();
答案 0 :(得分:0)
您可以为DataTemplate
值定义DateTime
-
<DataGrid>
<DataGrid.Resources>
<DataTemplate DataType="{x:Type DateTime}">
<TextBlock Text="{Binding StringFormat={0:d}}" />
</DataTemplate>
</DataGrid.Resources>
...
</DataGrid>