Syncfusion:WPF 打印预览中不必要的日期格式
Syncfusion : unnecessary Date format in print preview in WPF
我在 WPF 中使用 Syncfusion SFDatagrid,我想在字符串格式上显示日期。
var col = new CustomGridTextColumn();
col.HeaderText = ReportSourceDataTable.Columns[i].ToString();
col.DisplayBinding = new Binding(ReportSourceDataTable.Columns[i].ToString());
if (ReportSourceDataTable.Columns[i].DataType == typeof(DateTime))
{
col.DisplayBinding.StringFormat = "MM/dd/yyyy";
}
在主应用程序中,它工作正常。
但是当我预览或导出这些数据时,会应用不必要的 'MM/dd/yyyy' 字符串格式。以下是打印预览中的示例
谁能告诉我如何删除这种不必要的字符串格式?
您可以通过在 GridTextColumn 中设置 UseBindingValue 来实现在打印预览中显示正确日期格式的要求,如下所示,
<syncfusion:GridTextColumn MappingName="OrderDate" UseBindingValue="True" DisplayBinding="{Binding Path=OrderDate,StringFormat=MM/dd/yyyy}"/>
此致,
杰
我在 WPF 中使用 Syncfusion SFDatagrid,我想在字符串格式上显示日期。
var col = new CustomGridTextColumn();
col.HeaderText = ReportSourceDataTable.Columns[i].ToString();
col.DisplayBinding = new Binding(ReportSourceDataTable.Columns[i].ToString());
if (ReportSourceDataTable.Columns[i].DataType == typeof(DateTime))
{
col.DisplayBinding.StringFormat = "MM/dd/yyyy";
}
在主应用程序中,它工作正常。
但是当我预览或导出这些数据时,会应用不必要的 'MM/dd/yyyy' 字符串格式。以下是打印预览中的示例
谁能告诉我如何删除这种不必要的字符串格式?
您可以通过在 GridTextColumn 中设置 UseBindingValue 来实现在打印预览中显示正确日期格式的要求,如下所示,
<syncfusion:GridTextColumn MappingName="OrderDate" UseBindingValue="True" DisplayBinding="{Binding Path=OrderDate,StringFormat=MM/dd/yyyy}"/>
此致, 杰