窗口形成水晶报表

窗口形成水晶报表

本文介绍了C#窗口形成水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单选按钮吗?
1)风景
2)人像
然后,我单击打印"按钮,但未显示打印数据"
请为什么不取消打印页面中的数据分页.
请感谢C#Windows窗体的进步

I did I have two Radio button
1)Landscape
2)Portrait
Then I clicked the Printbutton but Print data is not displaying
plz why is not displanying data in the print out page.
plz thanks advance in C# windows forms

private void btnprint_Click(object sender, EventArgs e)
        {
            ReportDocument doc = new ReportDocument();
            ReportClass objRep = new ReportClass();
            LoadReport rpt = new LoadReport();

            PrintDocument docprint = new PrintDocument();

           if (rptName == "ContingenyPlanning")
            {
                objRep = rpt.CreateContingencyPlanning(clientid);

            }
              else if (rptName == "RetirementPlanning")
            {
                objRep = rpt.CreateRetirmentPlanning(clientid);

            }

            // like to print.
            printDialog1.AllowSomePages = true;

            // Show the help button.
            printDialog1.ShowHelp = true;


           // doc.PrintOptions.PrinterName = printDialog1.PrinterSettings.PrinterName;


            // Set the Document property to the PrintDocument for  
            // which the PrintPage Event has been handled. To display the 
            // dialog, either this property or the PrinterSettings property  
            // must be set 
            if (rdbLandscape.Checked == true)
            {
                docprint.DefaultPageSettings.Landscape = true;
                docprint.DefaultPageSettings.PrinterSettings.DefaultPageSettings.Landscape = true;

                //doc.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
            }
            else
            {
                docprint.DefaultPageSettings.Landscape = false;
                docprint.DefaultPageSettings.PrinterSettings.DefaultPageSettings.Landscape = false;
                //doc.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
            }


            if (rdbportrait.Checked == true)
            {
                docprint.DefaultPageSettings.Landscape = false;
                docprint.DefaultPageSettings.PrinterSettings.DefaultPageSettings.Landscape = false;
               // doc.PrintOptions.PaperOrientation = PaperOrientation.Portrait;

            }
            else
            {
                docprint.DefaultPageSettings.Landscape = true;
                docprint.DefaultPageSettings.PrinterSettings.DefaultPageSettings.Landscape = true;
                //doc.PrintOptions.PaperOrientation = PaperOrientation.Landscape;

            }

            printDialog1.Document = docprint;

            DialogResult result = printDialog1.ShowDialog();

            // If the result is OK then print the document. 
            if (result == DialogResult.OK)
            {
                docprint.Print();
            }
        }

private void document_PrintPage(object sender,
        System.Drawing.Printing.PrintPageEventArgs e)
        {

            // Insert code to render the page here. 
            // This code will be called when the control is drawn. 

            // The following code will render a simple 
            // message on the printed document. 
            string text = "In document_PrintPage method.";
            System.Drawing.Font printFont = new System.Drawing.Font
                ("Arial", 35, System.Drawing.FontStyle.Regular);

            // Draw the content.
            e.Graphics.DrawString(text, printFont,
                System.Drawing.Brushes.Black, 10, 10);
        }

推荐答案


这篇关于C#窗口形成水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 19:39