P
Peter Afonin
Hello,
I'm still learning Crystal reports, and now I need to sort report
programmatically. I've found a good article about it:
http://blogs.ittoolbox.com/c/coding...elds-in-crystal-report-programmatically-16201.
This is how it described there:
ReportDocument objReport = new ReportDocument();
objReport.Load("Your report path");
FieldDefinition FieldDef;
FieldDef = objReport .Database.Tables[0].Fields[sortField];
objReport.DataDefinition.SortFields[0].Field = FieldDef;
objReport.DataDefinition.SortFields[0].SortDirection =
CrystalDecisions.Shared.SortDirection.DescendingOrder;
When I try to do this, I'm getting an error on this line:
objReport.DataDefinition.SortFields[0].Field = FieldDef;
Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
This error is also described in this article:
"This is because you didn't define any sort field in your crytal report...
so if you try to add a FieldDef to the SortFields at a specified index and
that index doesn't exist then you will get the error..."
But there is no explanation how to define the sort fields in the report.
I've searched the Google and found several posts about the same issue, but
also no explanation.
So how can I define the sort fields for the report so I could sort
programmatically?
I would appreciate your help.
Thank you,
Peter
I'm still learning Crystal reports, and now I need to sort report
programmatically. I've found a good article about it:
http://blogs.ittoolbox.com/c/coding...elds-in-crystal-report-programmatically-16201.
This is how it described there:
ReportDocument objReport = new ReportDocument();
objReport.Load("Your report path");
FieldDefinition FieldDef;
FieldDef = objReport .Database.Tables[0].Fields[sortField];
objReport.DataDefinition.SortFields[0].Field = FieldDef;
objReport.DataDefinition.SortFields[0].SortDirection =
CrystalDecisions.Shared.SortDirection.DescendingOrder;
When I try to do this, I'm getting an error on this line:
objReport.DataDefinition.SortFields[0].Field = FieldDef;
Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
This error is also described in this article:
"This is because you didn't define any sort field in your crytal report...
so if you try to add a FieldDef to the SortFields at a specified index and
that index doesn't exist then you will get the error..."
But there is no explanation how to define the sort fields in the report.
I've searched the Google and found several posts about the same issue, but
also no explanation.
So how can I define the sort fields for the report so I could sort
programmatically?
I would appreciate your help.
Thank you,
Peter