Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I generate an ActiveReport dynamically in C# using an object

Posted on 2009-05-07
14
Medium Priority
?
650 Views
Last Modified: 2012-05-06
How do I generate an ActiveReport for a C# project dynamically using a object from the main project. I have an object referencing subobjects and I want to pass the whole class structure as my datasource to an ActiveReport from my C#.Net application.
The report will print something like this:
SECTION
----CATEGORY
----------SUBCATEGORY
-----------------QUESTION_TEXT, QUESTION_ANSWER

Open in new window

0
Comment
Question by:eddiecon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 8

Expert Comment

by:mac-will
ID: 24327716
Create a new 'object' datasource from the datasources panel
0
 

Author Comment

by:eddiecon
ID: 24327759
Thanks for responding so quickly. Can you be a bit more specific. Do you perhaps know of a walkthrough showing how to do this. My object is already created and I just want to pass my populated object to the report. Do my object need to adhere to a certain standard so that the report can understand it?
0
 
LVL 8

Expert Comment

by:mac-will
ID: 24327818
Go to the Data Menu -> Add New Datasource...

Select "Object" as the type and select your class as the object.

I don't know of any examples off hand but you could probably search for them on google
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:eddiecon
ID: 24327865
Thank you. Let me try your suggestion. I google'd for an answer but nothing really comes back that looks like what I want to do, but then I must say that I haven't worked yet through all the google'd pages that came back. So many pages, so little time. Let me see what I can do. Thanks once again.
0
 

Author Comment

by:eddiecon
ID: 24328167
I did what you suggested and it created an entry for my 'Object' datasource under my Reports assembly inside the Properties subfolder of the 'Reports' assembly. It created a subfolder under that called 'DataSources' and placed the entry inside that folder. I got exited because all that should be left to do is to open the 'Report Explorer' of my .Net IDE and drag the fields of the 'OBJECT' onto the report but there are no fields, just the layout of my report appears in the 'Report Explorer'.
I went down to the properties window for each field and GroupHeader on my report to see if the 'fields' of my OBJECT will appear in the dropdown of the 'DataField' property but there is nothing.
Am I doing something silly?
0
 
LVL 8

Expert Comment

by:mac-will
ID: 24338719
Datasource Objects only show object properties.  What you need to do is wrap your fields in a property.

(right-click on the fields and select encapsulate field)

Refresh and you should see all the public properties of the object.
0
 

Author Comment

by:eddiecon
ID: 24343074
Thank you very much mac-will. Will let you know if your suggestion sorted out my problem. Very much appreciated.
 
0
 

Author Comment

by:eddiecon
ID: 24350161
I still did not sort this out. Tell me, when you say "...wrap your fields in a property...", do you just refer to the creation of the getters and setters for each field in my class/object? Well I went through the encapsulation suggestion an all it did was creating another set of getters and setters in my class for each attribute/field in my class.

When you say "refresh" do you mean I should refresh the "Report Explorer" window so the fields should appear from where I can drag and drop them on my report?
0
 
LVL 8

Expert Comment

by:mac-will
ID: 24357075
Yes, Encapsualte == getters and setters (In the C# format of a class property)

Refresh the datasource so you can see the newly added PUBLIC properties.
0
 
LVL 8

Assisted Solution

by:mac-will
mac-will earned 80 total points
ID: 24357113
Here is a quick screenshot showing an object property as a datasource field.
demo.jpg
0
 

Author Comment

by:eddiecon
ID: 24361793
Ok. That was my understanding also.
The only difference between your image and my program is the following:
1. You don't have 'public' infront of your class declaration.
2. My object and it's fields are not appearing in the 'Data Sources' window.
I will keep trying. Must have done something wrong somewhere.
 
0
 

Author Comment

by:eddiecon
ID: 24366217
I got it working with a "flat structured" object. What I mean by that is that I have a small object with only two fields in it and no IList's of objects going from that object(embedded objects). I also discovered that after you created your object, that it is wrong to assume that it will be available to the DataSource add wizard. You have to rebuild your solution first and only then the object will be visible and available to be added as part of the DataSource you want to create. I know that perhaps to you all out there this might be general knowledge but I have overseen the mentioned.
I am now going to create a "big flat structured object" from my existing object which contains embeded objects. It will produce a "result set" as follows which I will then pass to the report as my DataSource:

SECTION_01, CATEGORY_01, SUBCATEGORY_01, QUESTION_01
SECTION_01, CATEGORY_01, SUBCATEGORY_01, QUESTION_02
SECTION_01, CATEGORY_01, SUBCATEGORY_02, QUESTION_01
SECTION_01, CATEGORY_01, SUBCATEGORY_02, QUESTION_02
SECTION_01, CATEGORY_02, SUBCATEGORY_01, QUESTION_01
SECTION_01, CATEGORY_02, SUBCATEGORY_01, QUESTION_02
SECTION_01, CATEGORY_02, SUBCATEGORY_02, QUESTION_01
SECTION_01, CATEGORY_02, SUBCATEGORY_02, QUESTION_02
SECTION_02, CATEGORY_01, SUBCATEGORY_01, QUESTION_01
SECTION_02, CATEGORY_01, SUBCATEGORY_01, QUESTION_02
SECTION_02, CATEGORY_01, SUBCATEGORY_02, QUESTION_01
SECTION_02, CATEGORY_01, SUBCATEGORY_02, QUESTION_02
SECTION_02, CATEGORY_02, SUBCATEGORY_01, QUESTION_01
SECTION_02, CATEGORY_02, SUBCATEGORY_01, QUESTION_02
SECTION_02, CATEGORY_02, SUBCATEGORY_02, QUESTION_01
SECTION_02, CATEGORY_02, SUBCATEGORY_02, QUESTION_02
etc., etc.
So my report should then print something like this: (--- replace spaces just for this message)
SECTION_01, CATEGORY_01, SUBCATEGORY_01, QUESTION_01
------------------------------------------------------------------------QUESTION_02
------------------------------------------, SUBCATEGORY_02, QUESTION_01
------------------------------------------------------------------------QUESTION_02
-------------------, CATEGORY_02, SUBCATEGORY_01, QUESTION_01
------------------------------------------------------------------------QUESTION_02
-----------------------------------------, SUBCATEGORY_02, QUESTION_01
------------------------------------------------------------------------QUESTION_02
SECTION_02, CATEGORY_01, SUBCATEGORY_01, QUESTION_01
------------------------------------------------------------------------QUESTION_02
-----------------------------------------, SUBCATEGORY_02, QUESTION_01
------------------------------------------------------------------------QUESTION_02
-------------------, CATEGORY_02, SUBCATEGORY_01, QUESTION_01
------------------------------------------------------------------------QUESTION_02
-----------------------------------------, SUBCATEGORY_02, QUESTION_01
------------------------------------------------------------------------QUESTION_02
etc., etc.

Will let you know as soon as I get it to work.
0
 

Accepted Solution

by:
eddiecon earned 0 total points
ID: 24367368
It works!!! Thank you mac-will for your patience.
I think I should slam together a walkthrough or at least a small example of what I have done. It might help others.
Thanks once again.
 
0
 
LVL 8

Expert Comment

by:mac-will
ID: 24386557
no problem - good luck
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question