I'm working with a Syncfusion SFDatagrid in WPF and I want to show date on the string format.
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";
}
In the main application, it works fine.
But when I preview or export those data, then an unnecessary 'MM/dd/yyyy' string format is applied. Below are examples from a print preview
Can anyone tell me how I can remove this unnecessary string format?
You can achieve your requirement to displaying the correct date format in print preview by setting the UseBindingValue in GridTextColumn like below,
<syncfusion:GridTextColumn MappingName="OrderDate" UseBindingValue="True" DisplayBinding="{Binding Path=OrderDate,StringFormat=MM/dd/yyyy}"/>
Regards, Jai