Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# and Crystal Report

Posted on 2011-02-23
8
Medium Priority
?
840 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 101

Accepted Solution

by:
mlmcc earned 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

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 101

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

782 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