Solved

C# and Crystal Report

Posted on 2011-02-23
8
828 Views
Last Modified: 2012-08-13
I have a C# project (VS2005) with a Crystal Report Viewer.  The code to call the crystal report is attached.  It prints a series of labels based upon a batch number in a table, then, if the user indicates a problem, does it again until the user says all is okay.

It is pointed at a Zebra ZM400 printer.

The report, if printed via Crystal itself, prints okay.  When it is called by the program, the orientation is wrong.

Any suggestions what to look at, what to do?  I can find nothing in the crv object that allows me to set orientation.
while (!Done)
                {
                    crvMain.ReportSource = this._PalletLabelPath;
                    crvMain.SelectionFormula = "{esna_PLUserInput.BatchId} = " + (char)34 + Batch + (char)34;

                    crvMain.PrintReport();

                    if (MessageBox.Show(this, "Did The Labels Print Correctly?", "Label Program", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //clear the screen and reset focus
                        this.ClearScreen2();

                        //set flag
                        Done = true;
                    }
                }

Open in new window

0
Comment
Question by:g_johnson
  • 4
  • 3
8 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 34964322
I don't believe there is anything in the viewer.

You need to use the report object.  It has the printer setup.  
This tutorial will show you how to do it
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
0
 
LVL 7

Expert Comment

by:jdavistx
ID: 34964348
With your crystal report open in Visual Studio...

Go to the "Crystal Reports" menu on the toolbar.
Go to "Design"
Go to "Page Setup"

See if that will let you set the desired orientation, and then try again.
0
 
LVL 4

Author Comment

by:g_johnson
ID: 34971795
The Crystal report is "stand-alone", i.e., not "in" VS.  In CRXI it is set to portrait mode.  

I have changed my code as follows, but it seems to have no affect on the printing.  We are getting inconsistent results.  Without changing anything in the program, under certain circumstances it prints landscape in others it prints portrait.  That seems to have to do with how we are connected as follows:  the app is installed on Machine A and Machine B.  If run directly from either machine, the orientation is wrong.  If we remote from Machine A to Machine B and run it from that remote session then the orientation is correct.  Also, from this remote session, we can choose either the remote or the local printer, and in both cases it prints correctly.

Here is my latest code:

                while (!Done)
                {
                    ReportDocument rd = new ReportDocument();
                    rd.Load(this._RollLabelPath);
                    if (this._Orientation == "P")
                        rd.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
                    else
                        rd.PrintOptions.PaperOrientation = PaperOrientation.Landscape;

                    crvMain.ReportSource = rd;

                    //crvMain.ReportSource = this._RollLabelPath;
                    crvMain.SelectionFormula = "{esna_LbLReptMast.BatchId} = " + (char)34 + BatchId + (char)34;

                    crvMain.PrintReport();

                    if (MessageBox.Show(this, "Did The Labels Print Correctly?", "Label Program", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //clear functional table
                        f.ClearTable(this._Conn, BatchId);

                        //clear the screen and reset focus
                        this.ClearScreen();

                        //set flag
                        Done = true;
                    }
                    else
                    {
                        //if start-over, get info, adjust table if necessary, and run Crystal again
                        fRestart fR = new fRestart();
                        fR.ConnString = this._Conn;
                        fR.BatchId = BatchId;

                        fR.ShowDialog();
                    }
                }
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 100

Expert Comment

by:mlmcc
ID: 34972788
Are you trying to change the orientation of the report on the fly?

Normally you set the printer to match the report developed orientation.

mlmcc
0
 
LVL 4

Author Comment

by:g_johnson
ID: 34973078
Well, what we're doing is troubleshooting.  We're not getting what we want when it's run from the program, though it runs fine from Crystal.  So we are tyring to force the issue via the program.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34973750
I found in some instances a report will switch the printer to Portrait but not the other way.  I set my printer to default to landscape since most of the reports were landscape and it seemed to work.

mlmcc
0
 
LVL 4

Author Comment

by:g_johnson
ID: 35008464
This turned out to be a driver issue.  However, I did find the one comment to be useful and will be awarding point accordingly.
0
 
LVL 4

Author Closing Comment

by:g_johnson
ID: 35008476
This does accurately answer the question of how to set the orientation programatically.  Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 62
2 questions 10 25
Where did System.Data.Objects go? 2 27
HTML - Color not displaying correctly in EMAIL. 6 37
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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