当前位置: 首页>>代码示例>>C#>>正文


C# PrintDialog.ShowDialog方法代码示例

本文整理汇总了C#中System.Windows.Forms.PrintDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# PrintDialog.ShowDialog方法的具体用法?C# PrintDialog.ShowDialog怎么用?C# PrintDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PrintDialog的用法示例。


在下文中一共展示了PrintDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupThePrinting

        // The printing setup function
        private bool SetupThePrinting()
        {
            PrintDialog MyPrintDialog = new PrintDialog();
               MyPrintDialog.AllowCurrentPage = false;
               MyPrintDialog.AllowPrintToFile = false;
               MyPrintDialog.AllowSelection = false;
               MyPrintDialog.AllowSomePages = false;
               MyPrintDialog.PrintToFile = false;
               MyPrintDialog.ShowHelp = false;
               MyPrintDialog.ShowNetwork = false;

               if (MyPrintDialog.ShowDialog() != DialogResult.OK)
            return false;
               MyPrintDocument.DocumentName = "Planilla de ventas peluquería";
               MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; //página horizontal
               //MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = false; //página vertical
               MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
               MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
               MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);

               //if (MessageBox.Show("¿Desea centrar el reporte en la pagina?",
               // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo,
               // MessageBoxIcon.Question) == DialogResult.Yes)
               // MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
               // MyPrintDocument, true, true, "Listado Completo de Facturas", new Font("Tahoma", 15,
               // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               //else
               string encabezado = "Vendedor: Cecilia Toscani             Zona: " + txtZona.Text + "               Fecha: " + DateTime.Now.ToLongDateString();
            MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
            MyPrintDocument, false, true, encabezado, new Font("Tahoma", 13,
            FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               return true;
        }
开发者ID:numenio,项目名称:Sistema-Ventas-Peluqueria,代码行数:34,代码来源:frmImprimir.cs

示例2: Printing

        public void Printing()
        {
            PrintDialog pDialog = new PrintDialog();
            FileStream fs = new FileStream(@"Szervíz_Feltételek.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            contract = sr.ReadToEnd();

            try
            {
                try
                {
                    PrintDocument pd = new PrintDocument();
                    pd.PrintPage += new PrintPageEventHandler(pd_PrintRent);

                    if (pDialog.ShowDialog() == DialogResult.OK)
                    {
                        pd.PrinterSettings = pDialog.PrinterSettings;
                        // Print the document.
                        pd.Print();
                    }

                }
                finally
                {

                }
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:sikisuti,项目名称:gyorok,代码行数:33,代码来源:printService.cs

示例3: _printButton_Click

        private void _printButton_Click(object sender, EventArgs e)
        {
            using (var form = new PrintDialog())
            using (var document = _document.CreatePrintDocument())
            {
                form.AllowSomePages = true;
                form.Document = document;
                form.UseEXDialog = true;
                form.Document.PrinterSettings.FromPage = 1;
                form.Document.PrinterSettings.ToPage = _document.PageCount;

                if (form.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    try
                    {
                        if (form.Document.PrinterSettings.FromPage <= _document.PageCount)
                            form.Document.Print();
                    }
                    catch
                    {
                        // Ignore exceptions; the printer dialog should take care of this.
                    }
                }
            }
        }
开发者ID:curveto-gh,项目名称:PdfViewer,代码行数:25,代码来源:PdfViewer.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            PrinterSettings ps = new PrinterSettings();
            pd.PrinterSettings = ps;
            DialogResult dr = pd.ShowDialog();

            if (dr == DialogResult.OK) {
                QRPrint printer = new QRPrint();
                printer.PrintMode = QRPrint.PrintModes.PsyBanknote;
                printer.NotesPerPage = (int)numVouchersPerPage.Value;
                switch (cboArtworkStyle.Text.ToLower()) {
                    case "yellow":
                    case "green":
                    case "blue":
                    case "purple":
                    case "greyscale":
                        printer.ImageFilename = "note-" + cboArtworkStyle.SelectedItem.ToString().ToLowerInvariant() + ".png";
                        break;
                }
                printer.Denomination = txtDenomination.Text;
                printer.keys = new List<KeyCollectionItem>(Items.Count);
                printer.PreferUnencryptedPrivateKeys = chkPrintUnencrypted.Checked;
                foreach (KeyCollectionItem a in Items) printer.keys.Add(a);
                printer.PrinterSettings = pd.PrinterSettings;
                printer.Print();
                PrintAttempted = true;
            }
        }
开发者ID:salfter,项目名称:Bitcoin-Address-Utility,代码行数:29,代码来源:PrintVouchers.cs

示例5: print

        public void print()
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 300, 100);
            ps.DefaultPageSettings.PaperSize = psize;

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;

            pdoc.DefaultPageSettings.PaperSize = psize;

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;

                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
开发者ID:hydrohead,项目名称:MWSZonBarcode,代码行数:30,代码来源:Printing.cs

示例6: A4PrintSelectPrint

        public bool A4PrintSelectPrint(string printContent, int printContentLineCount)
        {
            //PrintDocument doc = new TextDocument(printContent, printContentLineCount);
            PrintDocument doc = new TextDocument(printContent);//@Salim

            doc.PrintPage += this.printDocument1_PrintPage;

            PrintDialog printDialog1 = new PrintDialog();

            // pageSetupDialog1 = new PageSetupDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                // printDialog1.ShowDialog();

                if (printDialog1.PrinterSettings.PrinterName != null)
                {
                    if (printDialog1.PrinterSettings.PrinterName != null)
                    {
                        doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
                        // doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PaperSizes ;
                    }

                    doc.DefaultPageSettings.Landscape = true;
                    PrintDialog dlgSettings = new PrintDialog();
                    dlgSettings.Document = doc;

                    //if (dlgSettings.ShowDialog() == DialogResult.OK)
                    //{
                    doc.Print();
                }
            }
            return true;
        }
开发者ID:Jusharra,项目名称:RMS,代码行数:34,代码来源:PrintUtility.cs

示例7: print

        public void print()
        {
            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font =new Font("Arial",12);
            PaperSize psize = new PaperSize("Custome", 100, 200);
            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 320;
            pdoc.DefaultPageSettings.PaperSize.Width = 200;
            pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                ppd.Document = pdoc;
                result = ppd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();

                }
            }



        }
开发者ID:neyosuraj,项目名称:thisistestRepository,代码行数:28,代码来源:orderlist.cs

示例8: DoPrint

        public void DoPrint() {
            PrintDialog printDialog = new PrintDialog();

            docToPrint.DocumentName = this.documentName;
            printDialog.AllowSomePages = true;

            printDialog.ShowHelp = true;

            printDialog.Document = docToPrint;

            DialogResult result = printDialog.ShowDialog();

            docToPrint.PrintPage += new PrintPageEventHandler(document_PrintPage);

            pages = this.printPageList.Count;
            currentPage = 0;
            if (this.printPageList.Count <= 0)
                return;

            if (result == DialogResult.OK) {
                try {
                    docToPrint.Print();
                } catch (Exception e) {
                    MessageBox.Show("Fehler beim Drucken: " + e.ToString());
                }
            }
            
        }
开发者ID:tgassner,项目名称:WasserWerkVerwaltung,代码行数:28,代码来源:PrintableDocument.cs

示例9: buttonPrintImage_Click

        private void buttonPrintImage_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = this.printDocument1;
                if (printDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                /*
                PageSetupDialog pageSetupDialog = new PageSetupDialog();
                pageSetupDialog.Document = printDocument1;
                if (pageSetupDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                */
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = this.printDocument1;
                printPreviewDialog.ShowDialog();

            }
            catch (Exception)
            {
                MessageBox.Show("打印已经取消");
            }
        }
开发者ID:FieldSoft-HelloClyde,项目名称:MedicalRecordManagementSystem,代码行数:28,代码来源:ImageWindow.cs

示例10: StartPrint

        //Stream streamToPrint, string streamType
        //2�����Print��ӡ����
        public void StartPrint()
        {
            //����ֵ��PageSettings A4\A5
            PageSettings ps = new PageSettings();
            //��ʾ���ô�ӡҳ�Ի���
            PageSetupDialog Psdl = new PageSetupDialog();
            //��ӡ������ã�ע�⣬�÷��������printpage�������档
            PrintDialog pt = new PrintDialog();
            pt.AllowCurrentPage = true;
            pt.AllowSomePages = true;
            pt.AllowPrintToFile = true;
            //       StreamToPrint = streamToPrint;//��ӡ���ֽ���
            //       StreamType = streamType; //��ӡ������
            //       printDocument1.DocumentName = Filename; //��ӡ���ļ���
            Psdl.Document = printDocument1;
            //       PrintPreview.Document = printDocument1;
            pt.Document = printDocument1;
            Psdl.PageSettings = printDocument1.DefaultPageSettings;
            try
            {
                //ҳ�����öԻ���
                if (Psdl.ShowDialog() == DialogResult.OK)
                {
                    ps = Psdl.PageSettings;
                    printDocument1.DefaultPageSettings = Psdl.PageSettings;
                }
                //ѡ���ӡ���Ի���
                if (pt.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.PrinterSettings.Copies = pt.PrinterSettings.Copies;
                    //printDocument1.Print();
                    if (!checkBoxAll.Checked)
                    {
                        printDocument1.Print();
                    }
                    else
                    {
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            ShowTag(i);
                            printDocument1.Print();
                        }
                    }

                }
                ////��ӡԤ���Ի���
                //if (PrintPreview.ShowDialog() == DialogResult.OK)
                //{
                //    //���ô�ӡ
                //    printDocument1.Print();
                //}

                //PrintDocument�����Print()������PrintController����ִ��PrintPage�¼���
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
开发者ID:chutinhha,项目名称:asset-management-system,代码行数:62,代码来源:PrintDlg.cs

示例11: Print

 public override void Print(bool ShowDialog)
 {
     printDoc = new PrintDocument();
         printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
         pd = new PrintDialog();
         pd.Document = printDoc;
         pd.AllowSomePages = true;
         if ((!ShowDialog) || (pd.ShowDialog() == DialogResult.OK))
         {
             printDoc.DocumentName = "debuglog-" + DateTime.Now.Date.ToShortDateString() + ".txt";
             strPrintText = RawTrafficText.Text.Length > 0 ? RawTrafficText.Text : " ";
             switch (pd.PrinterSettings.PrintRange)
             {
                 case PrintRange.AllPages:
                     startPage = 1;
                     totalPages = pd.PrinterSettings.MaximumPage;
                     break;
                 case PrintRange.SomePages:
                     startPage = pd.PrinterSettings.FromPage;
                     totalPages = pd.PrinterSettings.ToPage - startPage + 1;
                     break;
             }
             // start printing
             pageNumber = 1;
             printDoc.Print();
         }
 }
开发者ID:HBelusca,项目名称:NasuTek-Odyssey-Tools,代码行数:27,代码来源:RawTraffic.cs

示例12: showPrintDialog

 internal static bool showPrintDialog(
     PrintDialog printDialog,
     ref string deviceName,
     ref string driverName,
     ref string port,
     ref csReportPaperType paperSize,
     ref int orientation,
     ref int fromPage,
     ref int toPage,
     ref int copies,
     ref int paperBin)
 {
     printDialog.AllowSomePages = true;
     var settings = printDialog.PrinterSettings;
     settings.PrinterName = deviceName;
     settings.FromPage = fromPage;
     settings.ToPage = toPage;
     settings.Copies = (short)copies;
     if (printDialog.ShowDialog() == DialogResult.OK)
     {
         deviceName = settings.PrinterName;
         fromPage = settings.FromPage;
         toPage = settings.ToPage;
         copies = settings.Copies;
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:javiercrowsoft,项目名称:CSReports.net,代码行数:31,代码来源:cPrintAPI.cs

示例13: Main

        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("sample.pdf");

            //Use the default printer to print all the pages
            //doc.PrintDocument.Print();

            //Set the printer and select the pages you want to print

            PrintDialog dialogPrint = new PrintDialog();
            dialogPrint.AllowPrintToFile = true;
            dialogPrint.AllowSomePages = true;
            dialogPrint.PrinterSettings.MinimumPage = 1;
            dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
            dialogPrint.PrinterSettings.FromPage = 1;
            dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;

            if (dialogPrint.ShowDialog() == DialogResult.OK)
            {
                //Set the pagenumber which you choose as the start page to print
                doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
                //Set the pagenumber which you choose as the final page to print
                doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
                //Set the name of the printer which is to print the PDF
                doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;

                PrintDocument printDoc = doc.PrintDocument;
                dialogPrint.Document = printDoc;
                printDoc.Print();
            }
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:32,代码来源:Program.cs

示例14: Imprimir

        public static void Imprimir(Entidades.Álbum.Álbum álbum, ItensImpressão itens)
        {
            using (PrintDocument documento = new PrintDocument())
            {
                documento.DocumentName = "Álbum " + álbum.Nome;

                using (PrintDialog dlg = new PrintDialog())
                {
                    dlg.AllowCurrentPage = false;
                    dlg.AllowSelection = false;
                    dlg.AllowSomePages = true;
                    dlg.UseEXDialog = true;
                    dlg.Document = documento;

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ControleImpressão ctrl = new ControleImpressão(álbum, itens);

                        ctrl.página = new Página(
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Width / 100f,
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Height / 100f,
                                4, 5);
            
                        ctrl.daPágina = dlg.PrinterSettings.FromPage;
                        ctrl.atéPágina = dlg.PrinterSettings.ToPage != 0 ?
                            dlg.PrinterSettings.ToPage : int.MaxValue;

                        documento.PrintPage += new PrintPageEventHandler(ctrl.ImprimirPágina);
                        documento.Print();
                    }
                }
            }
        }
开发者ID:andrepontesmelo,项目名称:imjoias,代码行数:33,代码来源:ControleImpressão.cs

示例15: btnin_Click

 private void btnin_Click(object sender, EventArgs e)
 {
     if(issave == false)
     {
         if(MessageBox.Show("Bạn phải lưu trước khi in, lưu ngay?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             btnluu.PerformClick();
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
         else
         {
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
     }
 }
开发者ID:trantuuit,项目名称:QLBanVeChuyenBay,代码行数:31,代码来源:LapPhieuDatCho.cs


注:本文中的System.Windows.Forms.PrintDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。