Articles in this section
Category / Section

How to handle the dates as strings in the WinForms PivotGridControl?

1 min read

Handle the dates as strings

When the date is set as a string format, it sorts the records based on the string and does not sort the record correctly in the Date string. So, use the dataset and apply the format property in the PivotItem class.

C#

//Sets date time column.
dt.Columns.Add("Date", GetType(DateTime))
//Sets Date Time format to the Pivot Row.
this.pivotGridControl1.PivotRows.Add(New PivotItem With {.FieldMappingName = "Date", .Format="MM/dd/yyyy", .TotalHeader = "Total"})

VB

‘Sets date time column
dt.Columns.Add("Date", GetType(DateTime))
‘Sets Date Time format to the Pivot Row.
Me.pivotGridControl1.PivotRows.Add(New PivotItem With {.FieldMappingName = "Date", .Format="MM/dd/yyyy", .TotalHeader = "Total"})

 

The following screenshots display the date strings before formatting and after formatting:

Display the date strings before formatting

Figure 1: Before formatting

Display the date strings after formatting

Figure 2: After formatting

Samples:

C#: Changing_Date_Format_CS

VB: Changing_Date_format_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied