|
-
Jul 7th, 2009, 01:30 PM
#1
Thread Starter
Addicted Member
Change the sorting field within groups on runtime
Hi. I'm using VS.net 2008 and CR 2008, and I've been trying to change the sorting field within a group during runtime. Here is the code I'm trying:
Code:
Dim myReport As New ReportDocument
Dim fielddef As FieldDefinition
fielddef = myReport.Database.Tables.Item(0).Fields.Item("startnummer")
myReport.DataDefinition.SortFields.Item(0).Field = fielddef
But it only changes the grouping, and I don't want to change that. Is it impossible to change the sorting field without affecting the grouping?
Hope you understand my problem, and thanks for all the help
-
Jul 7th, 2009, 03:41 PM
#2
Lively Member
Re: Change the sorting field within groups on runtime
I think you have to clear the existing sort order first. It is something like
vb Code:
myReport.DataDefinition.SortFields.clear
then specify the new sort order using AddItem or some other method
-
Jul 7th, 2009, 04:18 PM
#3
Re: Change the sorting field within groups on runtime
A Group is a SortField.
Loop through all the SortFields checking the SortFieldType for a RecordSortField. If you don't find one, add a new SortField. If you do modify it's FieldDefinition.
-
Jul 7th, 2009, 04:42 PM
#4
Thread Starter
Addicted Member
Re: Change the sorting field within groups on runtime
Thanks a lot Bruce! I made it work with this code:
Code:
fielddef = myReport.Database.Tables.Item(0).Fields.Item("startnummer")
For Each SortField In myReport.DataDefinition.SortFields
If SortField.SortType = SortFieldType.RecordSortField Then
SortField.Field = fielddef
End If
Next
But this code works only if it finds a RecordSortField. How do I add a new SortField if it can't find a RecordSortField?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|