コード例 #1
0
        //public void Print()

        //{

        //    try
        //    {

        //        XtraReport report = new XtraReport()
        //        {
        //            Name = "PrintMyData",
        //            DisplayName = "Recent Apps",
        //            PaperKind = PaperKind.Letter,
        //            Margins = new Margins(100, 100, 100, 100)
        //        };


        //        BindToData(report);
        //        CreateReportHeader(report, "Print Data");
        //        CreateDetail(report);
        //        CreateDetailReport(report);

        //        MyReport MyReport = new MyReport();
        //        MyReport.ReportDesigner.OpenDocument(report);
        //        MyReport.Show();

        //    }
        //    catch (Exception ex)
        //    {

        //        MessageBox.Show(ex.InnerException.Message);

        //    }
        //}

        public void Print()

        {
            try
            {
                MyReport1 = new XtraReport();

                //  ReportDesignTool MyReportDesignTool = new ReportDesignTool(MyReport1);

                MyReport1.Name        = "PrintMyData";
                MyReport1.DisplayName = "Recent Apps";
                MyReport1.PaperKind   = PaperKind.Letter;
                MyReport1.Margins     = new Margins(100, 100, 100, 100);


                BindToData(MyReport1);
                CreateReportHeader(MyReport1, "Print Data");
                CreateDetail(MyReport1);
                CreateDetailReport(MyReport1);

                MyReport1.ShowRibbonDesignerDialog();

                //   MyReportDesignTool.ShowRibbonDesignerDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }
        }
コード例 #2
0
        private void PrintSelection(Boolean details)
        {
            int parsedValue;

            if (!String.IsNullOrEmpty(txtName.Text) && !String.IsNullOrEmpty(txtHeight.Text) && !String.IsNullOrEmpty(cmbPrinters.SelectedItem.ToString()) && int.TryParse(txtWidth.Text, out parsedValue) && int.TryParse(txtHeight.Text, out parsedValue))
            {
                this.Cursor = Cursors.WaitCursor;
                DetailBand detail = new DetailBand();

                XtraReport quickPrint = new XtraReport()
                {
                    ReportUnit = ReportUnit.TenthsOfAMillimeter, PaperKind = PaperKind.Custom, PageWidth = Convert.ToInt32(txtWidth.Text) * 10, PageHeight = Convert.ToInt32(txtHeight.Text) * 10
                };
                quickPrint.Margins.Bottom = 0;
                quickPrint.Margins.Top    = 0;
                quickPrint.Margins.Left   = 0;
                quickPrint.Margins.Right  = 0;

                quickPrint.RequestParameters = false;
                quickPrint.Bands.AddRange(new Band[] { detail });
                quickPrint.Bands[BandKind.Detail].Controls.Add(new XRLabel()
                {
                    Text = txtName.Text, LocationF = new PointF(0, 0), Font = new Font("Segoe UI", 12)
                });
                quickPrint.Bands[BandKind.Detail].Controls.Add(CreateCode39BarCode(txtBarcode.Text));
                quickPrint.CreateDocument();
                quickPrint.PrintingSystem.Document.AutoFitToPagesWidth = 1;
                if (details)
                {
                    quickPrint.ShowRibbonDesignerDialog();
                }
                else
                {
                    quickPrint.Print(cmbPrinters.SelectedItem.ToString());
                }
                this.Cursor = Cursors.Default;
            }
            else
            {
                MessageBox.Show("Kağıt boyutlarını giriniz!", "Üzgünüm!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }