Question crystal reports programatically grouping help

ridhwaans

Active member
Joined
Jun 1, 2012
Messages
34
Programming Experience
3-5
Hi all,
I am a newbie to working with crystal reports in vb.net
The situation is, I've got a crystal report, a crystal report viewer, a database data source with a dataset, and a listview in a winforms application which has got a string collection as a list, something like

"1234 Project One- Stage 1"
"1235 Project Two- Stage 4"
"1236 Project Three- Stage 2"

The listview acts a a picklist where the user can basically 'Add' or 'Remove' such list items
When the user clicks a command button at runtime, the program open the crystal report viewer and displays the crystal report based on the listview items
The list items are actually concatenated as a string after retrieved from a database data source where the the 'project number', 'project name', and 'project stage' (all concatenated) are fields which come from three different tables.

Now, the 'project number' field actually has a parent key relationship with another table in the database, which means each project will have a collection of customer, phone number, address field information because that project number is a parent id. (all this data comes from the dataset from a database source)
The customer name, phone number, and address fields are already defined in the page header and details section.

The question is, how can I programmatically create, insert(add) and remove groups in the crystal report based on the number of projects (list items)? I want each item from the listview (for example "1234 Project One- Stage 1") to be a group which would display the customer name, phone number, and address fields contained in it.


For example, this is how the crystal report in the viewer would look like when executed if there were 3 items in the listview:

------------------------------------------------------------------------------------
Report 1 (Report Header)

Customer name phone number address (Page Header)
1234 Project One- Stage 1 (Group 1 Header)
Adam 5555 blah
Henry 8888 blah

1235 Project Two- Stage 4 (Group 2 Header)
Joe 7777 blah
James 3333 blah

1236 Project Three- Stage 2 (Group 3 Header)
John 2222 blah
Jason 9999 blah


So for example, at runtime if the listview had seven items, the crystal report would changed and display seven groups with the fields and headings. If the listview had zero items, the crystal report would be empty and display nothing

So, can someone please advise on how to implement this sort of thing?
I know vb.net crystal reports has a group expert which lets me insert new group headers at design time, but that is not runtime. when the user adds or removes items from the listview, the crystal report does not dynamically add or remove group headers and fields and info based on the listview.

I think it can be done using formula fields and parameter fields, but with crystal syntax I'm not sure how.
Can someone please advise on how to do it? Am I on the right track?

Thanks, this is important to me

Looking forward to your reply

Regards
 
Top Bottom