Crystal Reports Viewer in .Net GUI

Posted by jmgawlik on 09-Feb-2009 13:47

I am trying to use a Crystal 10 viewer in a form but I'm not sure what to use in the Advanced GUI tools. OCX or can I use a .dll?

Any ideas?

All Replies

Posted by Simon de Kraa on 09-Feb-2009 14:47

The first thing I would try is to install the Crystal .NET runtime and google some C# examples and try something similar in ABL.

Posted by jmgawlik on 09-Feb-2009 16:18

Well, I did find an example of adding the Crystal Report Viewer to a C# application. I have a copy of Visual Studio 2005 and was able to add a copy of the control to the windows form. What VS2005 does is add a bunch of references which, as of yet, I'm not able to duplicate.

Although, I'm posting this as more of an update any additional information would gladly be accepted.

Posted by Admin on 09-Feb-2009 16:43

Visual Studio 2005 and was able to add a copy of the

control to the windows form. What VS2005 does is add

a bunch of references which, as of yet, I'm not able

to duplicate.

Do you have a sample of those?

Posted by jmgawlik on 09-Feb-2009 17:06

Well, I guess it's not a lot of them but I am showing references to AxCrystalActiveXReportViewerLib10 and CrystalActiveXReportViewerLib10.

Posted by egarcia on 09-Feb-2009 17:50

Hello John,

I may have some suggestions but I need to understand your environment.

Do you have the CrystalReportViewer control for .NET?

Do you see the control in the CrystalDecisions.Windows.Forms assembly with the Object Browser in Visual Studio 2005?

How are you trying to use the control in a form?

How are you creating the reports?

I have been able to use the CrystalReportViewer. I used the CrystalReportViewer control in an ABL user control and then embed the ABL user control in an ABL form. I added an ABL property to expose the ReportSource property to the Visual Designer in OpenEdge Architect.

I had to add the CrystalDecisions.CrystalReports.Engine and the CrystalDecisions.Windows.Forms assemblies to assemblies.xml file.

I am attaching the wrapper program ReportViewer.cls in case that it is useful. Please consider that I wrote it for a test and it may need some improvements.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/ReportViewer.cls:550:0]

I hope this helps.

Posted by jmgawlik on 10-Feb-2009 10:22

Well, I have the Crystal 10 Runtime installed. And I am just trying to use the viewer to view pre-created reports. Hope that answers your question.

I will take a look at your code. Thank you for that.

Posted by jmgawlik on 10-Feb-2009 11:38

Sorry I'm pretty new to this stuff.

So you just added the entries to the assemblies.xml but do you have Version, Culture, and PublicKeyToken information? I've never used an ABL User Control either so I need to check that out too.

Posted by Simon de Kraa on 10-Feb-2009 12:26

You can modify the assemblies.xml file with the Assembly References Tool (menu OpenEdge, Tools, Assembly References).

It should be possible to add the Crystal Reports Viewer to you Toolbox (right mouse click, Add Controls, Global Assemblies, Filter on "Crystal").

Posted by jmgawlik on 10-Feb-2009 12:39

I must have done something wrong then because the Crystal isn't showing up in my Global Assemblies list.

Can I do this with just the Crystal Runtime? I can't remember.

Message was edited by:

John Gawlik

Dumb question, I just did it with my Visual Studio machine.

Message was edited by:

John Gawlik

Posted by Simon de Kraa on 10-Feb-2009 12:46

They should be there!

I tried it myself and installed CRRedist2005_x86.msi (CRRedist2008_x86.msi should work as well I think).

Used the Assembly References Tool to add the Crystal references. Saved the new assemblies.xml file in the project root.

Tried to add the CR Viewer to the Toolbox but then I got the error "Visual Designer does not support this controls" or something like that. You should probably wrap the CR viewer in an ABL Control like said earlier?

I could however create a Form and add the following code to visualize the CR Viewer (based on the code that was posted earlier).

DEFINE VARIABLE crystalReportViewer1 AS CrystalDecisions.Windows.Forms.CrystalReportViewer NO-UNDO.

crystalReportViewer1 = NEW CrystalDecisions.Windows.Forms.CrystalReportViewer().

crystalReportViewer1:ActiveViewIndex = -1.

crystalReportViewer1:BorderStyle = System.Windows.Forms.BorderStyle:FixedSingle.

crystalReportViewer1:Dock = System.Windows.Forms.DockStyle:Fill.

crystalReportViewer1:Location = new System.Drawing.Point(0, 0).

crystalReportViewer1:Name = "crystalReportViewer1".

crystalReportViewer1:SelectionFormula = "".

crystalReportViewer1:Size = new System.Drawing.Size(420, 320).

crystalReportViewer1:TabIndex = 0.

crystalReportViewer1:ViewTimeSelectionFormula = "".

Controls:Add(crystalReportViewer1).

Posted by Simon de Kraa on 10-Feb-2009 12:53

Some screenshots. Hope this helps.

Posted by jmgawlik on 10-Feb-2009 12:58

Well, I will try reinstalling the runtime then. I have an older version: CR10RDC.msi.

No luck...I wonder if it's version issue. We've never really bothered to upgrade from version 10.

Message was edited by:

John Gawlik

Neither my 10.1B machine or my 10.2A machine show Crystal Decisions of any kind in the Windows\assembly. I'm guessing that this might be related to the older version of the redistributable.

Message was edited by:

John Gawlik

Posted by egarcia on 10-Feb-2009 16:36

It seems that the runtime that you have, only includes the OCX version of the viewer.

If you can use a version of the runtime with the .NET version of the viewer then you could integrated it using the sample program from before.

Another option would be to use the OCX in an ABL window embedded in a .NET form.

See the chapter about "Embedding ABL windows in .NET forms" in the OpenEdge GUI for .NET guide.

I hope this gives you some ideas.

Posted by jmgawlik on 10-Feb-2009 16:53

I am currently downloading 11.2 right now and see if I have any better luck. I will definitely check into using the OCX as suggested. Fortunately, my boss is open to the idea of updating Crystal since we've put it off for so long.

Thank you all for you suggestions. I'll get this working one way or the other.

Posted by Roger Blanchard on 10-Feb-2009 17:13

John,

Be careful with Crystal as they have dropped support for com in newer versions. I do not know if that includes the ActiveX viewer but I would think so. Version XI is the last version to support com.

Posted by jmgawlik on 10-Feb-2009 17:19

So can someone clarify something for me? If an installation doesn't register an assembly with windows it can't be used in the ABL Forms? Another example would be being able to use the AcroPDF.dll from the \Program Files\Common Files\Adobe\Acrobat\ActiveX. Does the Advanced GUI not support these objects the same way as the .NET? I'm guessing not. I'm afraid I don't all that much about it.

Thanks for the information on the Crystal XI. We will have to check into our options carefully for sure.

Posted by Matt Baker on 10-Feb-2009 19:04

An assembly does not have to be registered in the GAC to use. The GAC makes it easy to find, but if you know the location of the .dll you can use it.

The ABL provides an alternate way using the -assemblies startup paramaeter. If you know where the assembly is, make a copy of it in a directory in your environment. For example create a directory called "assemblies" and put the .dll and its dependencies there. Then add a reference to the assemblies.xml file. Then add the -assemblies startup parmaeter to the prowin32.exe and point to the directory containng both the assemblies.xml file and the .dll you are using

e.g.

Project\

assemblies\

assemblies.xml

myassembly.dll

c:\project\prowin32.exe -assemblies c:\project\assemblies\

Posted by Simon de Kraa on 11-Feb-2009 01:53

I downloaded CRRedist2005_x86.msi from somewhere on the internet.

BTW

When I try to add the CR controls to the toolbox I get a "not support by VD" error. See attachment. Does this mean you have to wrap the CR controls into an ABL control in order to add it to the toolbox? If so, will the ABL control visualize the CR controls?

Posted by Matt Baker on 11-Feb-2009 08:27

There are some controls that visual designer prohibits from being added to the toolbox/design window. This is because they are known not to work at design time for various reasons. This does not mean that they do not work at run time. Usually because they require some functionality that is only available from Visual Studio. In such cases you will get an error message when you try to add it to the toolbox.

Look at Edsel's example of how to create your own ABL control wrapper around the Crystal Reports viewer.

Posted by jmgawlik on 12-Feb-2009 16:36

Okay, just an update (I haven't gotten to work on this much). I installed the Crystal 11.2 and was finally able to add the assemblies to the assemblies xml document. This allowed to create a user control wrapper.

I have since dropped that user control to a form and can open a report. Now I just need to figure out how to get the login to be automatic and send in the parameters and I'm good.

Thanks again everyone.

This thread is closed