0

I am developing application in C# Windows Forms, i make crystal reports on the basis of data collection list in c#, for example i have a table having EmpID, Name, Sponsor, Job Title, Nationality etc. I bring them in collection in c# and pass it to crystal report, where i see my attributes in Database fields, if i drag and drop those fields on the report, for example Name, Job Title, Nationality, then i can see their columns coming in Details section, but the issue is, i have about 25 attributes and i have made a check list of 25 attributes in c#, if i check 13 attributes, it should make a report of 13 columns, the problem is, we make report in crystal report on the basis of drag and dropping fields, how can i dynamically do this, means if there are 13 fields selected in c# check list, there should be just 13 columns in report. Please find the image attached, "How currently i am doing" Please zoom it by right click on it, and open in new window. enter image description here

1
  • I just want to know, how can we i make a report on the basis of columns selected in c# check list, just it is simle, why i am not getting any answer, is their no such solution? Nov 21, 2011 at 12:02

4 Answers 4

1
+50

I think that the easiest way to approach this, considering data type representations and all of the Crystal complexity under the covers, is to layout your report with all 25 fields sized appropriately.

Then, at runtime, you will need to reposition the report objects, which could be a little tricky due to the relatively unstructured way in which crystal provides the information.

The way I would approach this is to loop through the report objects and generate one SortedList for the data fields and one SortedList for the header fields. They should be sorted on their Left position so that you can process them in appearance order.

Once you have the sorted lists of objects, you can cycle through each one and, if it was not selected by the user, set the Width to 0.

As you are moving through the fields, you will keep track of the current left position. The first field that you process will set your starting point, even if it is not visible. Then, for all subsequent fields, if the field is visible, you will set its left value to the current left position, then add its width plus some separator space to the current left position for the next field.

Hopefully this will help you solve your problem.

0

It sounds like this would be a good place for a cross-tab report. In this case you'd need to add a cross tab to your report header or footer and pass your data into the report with a column for each attribute descriptions and then group on the attribute description. See below for details:

Data:

RowID  ColDesc    ColValue
1      Attr1      Value1
1      Attr2      Value2
2      Attr1      Value3

Then you can add your crosstab where your row field is RowID, your column field is ColDesc and the field to summarize is ColValue. You can use a Max of summary on the summarized field since it is different.

This is untested, but I believe that the output for this should be:

CrossTab:

       Attr1    Attr2
1      Value1   Value2
2      Value3 

As you can see that as you add a new attribute it will show up as a new column in the crosstab. As I said previously, this is untested so I apologize for any errors, but I hope it is enough to help you out. Thanks

0

Give a look at these links

Using this Google Search

0

Crystal Reports will not automatically add columns & headers to a report given a list of fields.

My recommendation is to use the Report Application Server .NET SDK to dynamically alter a report. The link includes the API reference, as well as samples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.