WinForm Call PrintDocument

Source: Internet
Author: User

Print Devexpress barcodecontrol QR code using WinForm

        /// <summary>        ///Handles The ItemClick event of the barButtonItem2 control. /// </summary>        /// <param name= "Sender" >The source of the event.</param>        /// <param name= "E" > the<see cref= "DevExpress.XtraBars.ItemClickEventArgs"/>instance containing the event data.</param>        Private voidBarbuttonitem2_itemclick (Objectsender, DevExpress.XtraBars.ItemClickEventArgs e) {printdialog1.document=PrintDocument1; Printpreviewcontrol1.document=PrintDocument1; Printdocument1.printpage+=Printdocument1_printpage; if(Printdialog1.showdialog () = =DialogResult.OK) {printdocument1.print (); }        }        /// <summary>        ///Prints to graphics. /// </summary>        /// <param name= "Graphics" >The graphics.</param>        /// <param name= "Bounds" >The bounds.</param>         Public voidPrinttographics (graphics graphics, Rectangle bounds) {Bitmap Bitmap=NewBitmap (Barcodecontrol1.width, barcodecontrol1.height); Barcodecontrol1.drawtobitmap (Bitmap,NewRectangle (0,0, Bitmap. Width, Bitmap.            Height)); Rectangle Target=NewRectangle (0,0, bounds. Width, bounds.            Height); DoubleXScale = (Double) bitmap. Width/bounds.            Width; DoubleYscale = (Double) bitmap. Height/bounds.            Height; if(XScale <Yscale) target. Width= (int) (XScale * target. Width/Yscale); ElseTarget. Height= (int) (Yscale * target. Height/XScale); Graphics. PageUnit=Graphicsunit.display; Graphics.        DrawImage (bitmap, target); }        /// <summary>        ///Handles The PrintPage event of the PrintDocument1 control. /// </summary>        /// <param name= "Sender" >The source of the event.</param>        /// <param name= "E" > the<see cref= "System.Drawing.Printing.PrintPageEventArgs"/>instance containing the event data.</param>        Private voidPrintdocument1_printpage (Objectsender, System.Drawing.Printing.PrintPageEventArgs e)        {Printtographics (e.graphics, e.marginbounds); }

WinForm Call PrintDocument

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.